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;
namespace D {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var X = Console.ReadLine();
var fn = new int[N + 1];
fn[1] = 1;
for (int i = 2; i <= N; i++) {
var temp = i % popcount(i);
fn[i] = fn[temp] + 1;
}
var count1 = X.Length - X.Replace("1", "").Length;
var modPlus = 0;
var modMinus = 0;
var modp = 1;
var modm = 1;
for (int i = N - 1; i >= 0; i--) {
if (X[i] == '1') {
modPlus += modp;
modPlus %= count1 + 1;
modMinus += modm;
modMinus %= count1 - 1;
}
modp = (modp * 2) % (count1 + 1);
modm = (modm * 2) % (count1 - 1);
}
var Xi = new int[N];
modp = 1;
modm = 1;
for (int i = N - 1; i >= 0; i--) {
if (X[i] == '1') {
if (modMinus - modm < 0)
modMinus += count1 - 1;
Xi[i] = fn[(modMinus - modm) % (count1 - 1)] + 1;
} else {
if (modPlus - modp < 0)
modPlus += count1 + 1;
Xi[i] = fn[(modPlus + modp) % (count1 + 1)] + 1;
}
modp = (modp * 2) % (count1 + 1);
modm = (modm * 2) % (count1 - 1);
}
Console.WriteLine(string.Join("\n", Xi));
}
static int popcount(int X) {
var result = 0;
while (X > 0) {
if ((X % 2) == 1)
result++;
X /= 2;
}
return result;
}
}
}
|
using System;
namespace D {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var X = Console.ReadLine();
var fn = new int[N + 1];
fn[1] = 1;
for (int i = 2; i <= N; i++) {
var temp = i % popcount(i);
fn[i] = fn[temp] + 1;
}
var count1 = X.Length - X.Replace("1", "").Length;
var modPlus = 0;
var modMinus = 0;
var modp = 1;
var modm = 1;
for (int i = N - 1; i >= 0; i--) {
if (X[i] == '1') {
modPlus += modp;
modPlus %= count1 + 1;
if (count1 > 1) {
modMinus += modm;
modMinus %= count1 - 1;
}
}
modp = (modp * 2) % (count1 + 1);
if (count1 > 1)
modm = (modm * 2) % (count1 - 1);
}
var Xi = new int[N];
modp = 1;
modm = 1;
for (int i = N - 1; i >= 0; i--) {
if (X[i] == '1') {
if (count1 > 1) {
if (modMinus - modm < 0)
modMinus += count1 - 1;
Xi[i] = fn[(modMinus - modm) % (count1 - 1)] + 1;
} else {
Xi[i] = 0;
}
} else {
if (modPlus - modp < 0)
modPlus += count1 + 1;
Xi[i] = fn[(modPlus + modp) % (count1 + 1)] + 1;
}
modp = (modp * 2) % (count1 + 1);
if (count1 > 1)
modm = (modm * 2) % (count1 - 1);
}
Console.WriteLine(string.Join("\n", Xi));
}
static int popcount(int X) {
var result = 0;
while (X > 0) {
if ((X % 2) == 1)
result++;
X /= 2;
}
return result;
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 430
| 38
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
// using System.Threading.Tasks;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<long, long>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
readonly Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
readonly int mod = 1000000007;
readonly int dom = 998244353;
bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (b.CompareTo(a) < 0) {
a = b;
return true;
}
return false;
}
void solve() {
int N = cin.nextint;
var dp = new int[N + 1];
for (int i = 0; i <= N; i++) {
int cnt = 0;
long j = i;
while (popcnt(j) != 0) {
j %= popcnt(j);
cnt++;
}
dp[i] = cnt;
// WriteLine($"i:{i} popcnt(i):{popcnt(i)} times:{cnt}");
}
//各ビットの寄与を求める
var X = cin.next;
var B = X.Count(i => i == '1');
var v = B + 1;
var s = B - 1;
var Y = X.reverse();
var pop = new pair[N];
var down = new pair[N];
long kv = 1;
long ks = 1;
long kvsum = 0;
long kssum = 0;
for (int i = 0; i < N; i++) {
if (Y[i] == '1') {
pop[i] = new pair(kv, ks);
kvsum += kv;
kssum += ks;
} else {
down[i] = new pair(kv, ks);
}
kv = kv * 2 % v;
ks = ks * 2 % s;
}
for (int i = N - 1; i >= 0; i--) {
// sで割る
if (Y[i] == '1') {
var tmp = kssum - pop[i].s;
tmp %= s;
WriteLine(dp[tmp] + 1);
}
// vで割る
else {
var tmp = kvsum + down[i].f;
tmp %= v;
WriteLine(dp[tmp] + 1);
}
}
}
long popcnt(long n) {
long c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555);
c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333);
c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f);
c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff);
c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff);
c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff);
return c;
}
}
static class Ex {
public static void join<T>(this IEnumerable<T> values, string sep = " ") =>
WriteLine(string.Join(sep, values));
public static string
concat<T>(this IEnumerable<T> values) => string.Concat(values);
public static string reverse(this string s) {
var t = s.ToCharArray();
Array.Reverse(t);
return t.concat();
}
public static int lower_bound<T>(this IList<T> arr, T val)
where T : IComparable<T> {
int low = 0, high = arr.Count;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (arr[mid].CompareTo(val) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int upper_bound<T>(this IList<T> arr, T val)
where T : IComparable<T> {
int low = 0, high = arr.Count;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (arr[mid].CompareTo(val) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
}
class Pair<T, U> : IComparable<Pair<T, U>>
where T : IComparable<T>
where U : IComparable<U> {
public T f;
public U s;
public Pair(T f, U s) {
this.f = f;
this.s = s;
}
public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0
? f.CompareTo(a.f)
: s.CompareTo(a.s);
public override string ToString() => $"{f} {s}";
}
class Scanner {
string[] s;
int i;
readonly char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan => ReadLine().Split();
public int[] scanint => Array.ConvertAll(scan, int.Parse);
public long[] scanlong => Array.ConvertAll(scan, long.Parse);
public double[] scandouble => Array.ConvertAll(scan, double.Parse);
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint => int.Parse(next);
public long nextlong => long.Parse(next);
public double nextdouble => double.Parse(next);
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using SB = System.Text.StringBuilder;
// using System.Threading.Tasks;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
using System.Numerics;
using static System.Math;
using pair = Pair<long, long>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
readonly Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
readonly int mod = 1000000007;
readonly int dom = 998244353;
bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (b.CompareTo(a) < 0) {
a = b;
return true;
}
return false;
}
void solve() {
int N = cin.nextint;
var dp = new int[N + 1];
for (int i = 0; i <= N; i++) {
int cnt = 0;
long j = i;
while (popcnt(j) != 0) {
j %= popcnt(j);
cnt++;
}
dp[i] = cnt;
// WriteLine($"i:{i} popcnt(i):{popcnt(i)} times:{cnt}");
}
//各ビットの寄与を求める
var X = cin.next;
var B = X.Count(i => i == '1');
var v = B + 1;
var s = B - 1;
var Y = X.reverse();
var pop = new pair[N];
var down = new pair[N];
long kv = 1;
long ks = 1;
long kvsum = 0;
long kssum = 0;
for (int i = 0; i < N; i++) {
if (Y[i] == '1') {
pop[i] = new pair(kv, ks);
kvsum += kv;
kssum += ks;
} else {
down[i] = new pair(kv, ks);
}
kv = kv * 2 % v;
if (s > 0)
ks = ks * 2 % s;
}
for (int i = N - 1; i >= 0; i--) {
// sで割る
if (Y[i] == '1') {
var tmp = kssum - pop[i].s;
if (s > 0) {
tmp %= s;
WriteLine(dp[tmp] + 1);
} else {
WriteLine(0);
}
}
// vで割る
else {
var tmp = kvsum + down[i].f;
tmp %= v;
WriteLine(dp[tmp] + 1);
}
}
}
long popcnt(long n) {
long c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555);
c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333);
c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f);
c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff);
c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff);
c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff);
return c;
}
}
static class Ex {
public static void join<T>(this IEnumerable<T> values, string sep = " ") =>
WriteLine(string.Join(sep, values));
public static string
concat<T>(this IEnumerable<T> values) => string.Concat(values);
public static string reverse(this string s) {
var t = s.ToCharArray();
Array.Reverse(t);
return t.concat();
}
public static int lower_bound<T>(this IList<T> arr, T val)
where T : IComparable<T> {
int low = 0, high = arr.Count;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (arr[mid].CompareTo(val) < 0)
low = mid + 1;
else
high = mid;
}
return low;
}
public static int upper_bound<T>(this IList<T> arr, T val)
where T : IComparable<T> {
int low = 0, high = arr.Count;
int mid;
while (low < high) {
mid = ((high - low) >> 1) + low;
if (arr[mid].CompareTo(val) <= 0)
low = mid + 1;
else
high = mid;
}
return low;
}
}
class Pair<T, U> : IComparable<Pair<T, U>>
where T : IComparable<T>
where U : IComparable<U> {
public T f;
public U s;
public Pair(T f, U s) {
this.f = f;
this.s = s;
}
public int CompareTo(Pair<T, U> a) => f.CompareTo(a.f) != 0
? f.CompareTo(a.f)
: s.CompareTo(a.s);
public override string ToString() => $"{f} {s}";
}
class Scanner {
string[] s;
int i;
readonly char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan => ReadLine().Split();
public int[] scanint => Array.ConvertAll(scan, int.Parse);
public long[] scanlong => Array.ConvertAll(scan, long.Parse);
public double[] scandouble => Array.ConvertAll(scan, double.Parse);
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint => int.Parse(next);
public long nextlong => long.Parse(next);
public double nextdouble => double.Parse(next);
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 213, 63, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 1,281
| 22
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
using System.Text;
namespace エイシングプログラミングコンテスト2020D {
class Program {
static void Main(string[] args) {
var N = RInt;
var X = Console.ReadLine();
int count1 = 0;
int count2 = 0;
for (int i = 0; i < N; i++) {
if (X[i] == '1') {
count1++;
count2++;
}
}
count1++;
count2--;
long sum1 = 0;
long sum2 = 0;
long[] mul1 = new long[N];
long[] mul2 = new long[N];
mul1[N - 1] = 1;
mul2[N - 1] = 1;
for (int i = N - 1; i >= 0; i--) {
if (X[i] == '1') {
sum1 += mul1[i];
sum2 += mul2[i];
}
if (i > 0) {
mul1[i - 1] = mul1[i] * 2;
mul2[i - 1] = mul2[i] * 2;
mul1[i - 1] %= count1;
mul2[i - 1] %= count2;
}
sum1 %= count1;
sum2 %= count2;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < N; i++) {
if (X[i] == '1') {
var sum = sum2 + count2 - mul2[i];
sum %= count2;
int ans = Rem(sum) + 1;
sb.AppendLine(ans.ToString());
} else {
var sum = sum1 + mul1[i];
sum %= count1;
int ans = Rem(sum) + 1;
sb.AppendLine(ans.ToString());
}
}
Console.Write(sb);
}
static int Rem(long num) {
if (num == 0)
return 0;
int count = 0;
string S = Convert.ToString(num, 2);
for (int i = 0; i < S.Length; i++) {
if (S[i] == '1')
count++;
}
num = num % count;
return Rem(num) + 1;
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//以下未テスト
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a % mod, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
using System.Text;
namespace エイシングプログラミングコンテスト2020D {
class Program {
static void Main(string[] args) {
var N = RInt;
var X = Console.ReadLine();
// for (int m = 1; m < 1000; m++)
//{
// X = Convert.ToString(m, 2);
// N = X.Length;
int count1 = 0;
int count2 = 0;
for (int i = 0; i < N; i++) {
if (X[i] == '1') {
count1++;
count2++;
}
}
count1++;
count2--;
long sum1 = 0;
long sum2 = 0;
long[] mul1 = new long[N];
long[] mul2 = new long[N];
mul1[N - 1] = 1;
mul2[N - 1] = 1;
for (int i = N - 1; i >= 0; i--) {
if (X[i] == '1') {
sum1 += mul1[i];
sum2 += mul2[i];
}
if (i > 0) {
mul1[i - 1] = mul1[i] * 2;
mul2[i - 1] = mul2[i] * 2;
mul1[i - 1] %= count1;
if (count2 != 0)
mul2[i - 1] %= count2;
}
sum1 %= count1;
if (count2 != 0)
sum2 %= count2;
else
sum2 = 0;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < N; i++) {
if (X[i] == '1') {
var sum = sum2 + count2 - mul2[i];
if (count2 != 0)
sum %= count2;
else
sum = 0;
int ans = Rem(sum) + 1;
if (count2 == 0)
ans = 0;
sb.AppendLine(ans.ToString());
} else {
var sum = sum1 + mul1[i];
sum %= count1;
int ans = Rem(sum) + 1;
sb.AppendLine(ans.ToString());
}
}
//}
Console.Write(sb);
}
static int Rem(long num) {
if (num == 0)
return 0;
int count = 0;
string S = Convert.ToString(num, 2);
for (int i = 0; i < S.Length; i++) {
if (S[i] == '1')
count++;
}
num = num % count;
return Rem(num) + 1;
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//以下未テスト
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a % mod, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 75, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 64, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 57, 75, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 75, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 57, 64, 1, 0, 11, 12, 203]]
| 8
| 1,536
| 38
|
using System;
namespace ABC_173_A_C_sharp_ver {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
for (int i = 1; i <= 10; i++) {
N %= (i * 1000);
if (N % 1000 == 0) {
break;
}
}
Console.WriteLine(N.ToString());
Console.ReadKey();
}
}
}
|
using System;
namespace ABC_173_A_C_sharp_ver {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int s = 0;
for (int i = 1; i <= 10; i++) {
N %= (i * 1000);
if (N % 1000 == 0) {
break;
}
s = 1000 - N;
}
// N = (1000 - N % 1000) % 1000;
Console.WriteLine(s.ToString());
Console.ReadKey();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22]]
| 8
| 89
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderExamCS {
class Program {
static void Main(string[] args) {
int N, answer = 0;
N = int.Parse(Console.ReadLine());
for (int i = 1; i <= 10; i++) {
if (N < i * 1000) {
answer = i * 1000 - N;
break;
}
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderExamCS {
class Program {
static void Main(string[] args) {
int N, answer = 0;
N = int.Parse(Console.ReadLine());
for (int i = 1; i <= 10; i++) {
if (N == 0) {
break;
}
if (N <= i * 1000) {
answer = i * 1000 - N;
break;
}
}
Console.WriteLine(answer);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19]]
| 8
| 109
| 12
|
using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using static Program.IO.Scanner;
using Number = System.Int64;
using System.Numerics;
#region IO
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)) {}
}
static public class Scanner {
public static StreamScanner sc =
new StreamScanner(Console.OpenStandardInput());
public static int ri => sc.Integer();
public static long rl => sc.Long();
public static string rs => sc.Scan();
public static double rd => sc.Double();
}
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 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 = false });
var solver = new Program.Solver();
var t = new System.Threading.Thread(solver.Solve, 50000000);
t.Start();
t.Join();
//*/
// solver.Solve();
Console.Out.Flush();
}
}
#endregion
namespace Program {
public class Solver {
Random rnd = new Random(0);
public void Solve() {
var n = ri;
var a = Enumerate(n, x => rl);
Array.Sort(a);
Array.Reverse(a);
var ans = new List<long>();
ans.Add(a[0]);
for (int i = 1; i < n; i++)
ans.Add(a[i]);
var res = ans.Take(n - 1).Sum();
Console.WriteLine(res);
}
const long INF = 1L << 60;
static int[] dx = { -1, 0, 1, 0 };
static int[] dy = { 0, 1, 0, -1 };
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 T[][] Enumerate<T>(int n, int m, Func<int, int, T> f) {
return Enumerate(n, x => Enumerate(m, y => f(x, y)));
}
static public void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using static Program.IO.Scanner;
using Number = System.Int64;
using System.Numerics;
#region IO
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)) {}
}
static public class Scanner {
public static StreamScanner sc =
new StreamScanner(Console.OpenStandardInput());
public static int ri => sc.Integer();
public static long rl => sc.Long();
public static string rs => sc.Scan();
public static double rd => sc.Double();
}
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 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 = false });
var solver = new Program.Solver();
var t = new System.Threading.Thread(solver.Solve, 50000000);
t.Start();
t.Join();
//*/
// solver.Solve();
Console.Out.Flush();
}
}
#endregion
namespace Program {
public class Solver {
Random rnd = new Random(0);
public void Solve() {
var n = ri;
var a = Enumerate(n, x => rl);
Array.Sort(a);
Array.Reverse(a);
var ans = new List<long>();
ans.Add(a[0]);
for (int i = 1; i < n; i++) {
ans.Add(a[i]);
ans.Add(a[i]);
}
Debug.WriteLine(ans.AsJoinedString());
var res = ans.Take(n - 1).Sum();
Console.WriteLine(res);
}
const long INF = 1L << 60;
static int[] dx = { -1, 0, 1, 0 };
static int[] dy = { 0, 1, 0, -1 };
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 T[][] Enumerate<T>(int n, int m, Func<int, int, T> f) {
return Enumerate(n, x => Enumerate(m, y => f(x, y)));
}
static public void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25]]
| 8
| 1,003
| 23
|
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();
var A = GetLongs(N);
Array.Sort(A);
Array.Reverse(A);
WriteLine(A.Take((int)N - 1).Sum());
}
}
public static class MyIO {
private static string[] args = new string[0];
private static int cnt = 0;
private static IEnumerable<string>
getArgs(long N) => Range(0, N).Select(_ => getArg());
private static string getArg() {
if (cnt == args.Length) {
args = Console.ReadLine().Split();
cnt = 0;
}
return args[cnt++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
public static long[] GetLongs(long N) =>
getArgs(N).Select(long.Parse).ToArray();
public static double[] GetDoubles(long N) =>
getArgs(N).Select(double.Parse).ToArray();
public static decimal[] GetDecimals(long N) =>
getArgs(N).Select(decimal.Parse).ToArray();
public static string[] GetStrings(long N) => getArgs(N).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;
}
public static long rightShift(long x, long y) => (x >> (int)y);
public static long leftShift(long x, long y) => (x << (int)y);
public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
public static long lcm(long x, long y) => (x / gcd(x, y)) * y;
public static IEnumerable<int>
Range(long start, long count) => Enumerable.Range((int)start, (int)count);
public static void
Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}
|
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();
var A = GetLongs(N);
Array.Sort(A);
Array.Reverse(A);
long ans = A[0];
for (long i = 1; i < N - 1; i++)
ans += A[(i + 1) / 2];
WriteLine(ans);
}
}
public static class MyIO {
private static string[] args = new string[0];
private static int cnt = 0;
private static IEnumerable<string>
getArgs(long N) => Range(0, N).Select(_ => getArg());
private static string getArg() {
if (cnt == args.Length) {
args = Console.ReadLine().Split();
cnt = 0;
}
return args[cnt++];
}
public static int GetInt() => int.Parse(getArg());
public static long GetLong() => long.Parse(getArg());
public static double GetDouble() => double.Parse(getArg());
public static decimal GetDecimal() => decimal.Parse(getArg());
public static string GetString() => getArg();
public static char GetChar() => getArg()[0];
public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
public static long[] GetLongs(long N) =>
getArgs(N).Select(long.Parse).ToArray();
public static double[] GetDoubles(long N) =>
getArgs(N).Select(double.Parse).ToArray();
public static decimal[] GetDecimals(long N) =>
getArgs(N).Select(decimal.Parse).ToArray();
public static string[] GetStrings(long N) => getArgs(N).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;
}
public static long rightShift(long x, long y) => (x >> (int)y);
public static long leftShift(long x, long y) => (x << (int)y);
public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
public static long lcm(long x, long y) => (x / gcd(x, y)) * y;
public static IEnumerable<int>
Range(long start, long count) => Enumerable.Range((int)start, (int)count);
public static void
Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}
|
[["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 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], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 39, 199], ["-", 3, 4, 0, 28, 0, 16, 31, 74, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 7, 8, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 7, 8, 1, 0, 11, 12, 204, 205, 22], ["+", 8, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 85], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 8, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 7, 8, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 730
| 41
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public static void Main(string[] args) { new D().test(); }
}
public class A {
public void test() {
// 普通の数値
var yen = CommonRead.ReadInt();
if (yen % 1000 == 0) {
Console.WriteLine(0);
} else {
Console.WriteLine(1000 - yen % 1000);
}
}
}
public class B {
public void test() {
// 普通の数値
var yen = CommonRead.ReadInt();
var name = new List<string>();
name.Add("AC");
name.Add("WA");
name.Add("TLE");
name.Add("RE");
var AC = new List<string>();
// var WA = new List<string>();
// var TLE = new List<string>();
// var RE = new List<string>();
// 繰り返し回数
for (int count = 0; count < yen; count++) {
AC.Add(CommonRead.ReadStr());
}
foreach (string sn in name) {
Console.WriteLine(sn + " x " + AC.Count(str => str == sn));
}
}
}
public class C {
public void test() {
// 普通の数値
var hwk = CommonRead.ReadIntL();
var row = new List<List<string>>();
for (int count = 0; count < hwk[0]; count++) {
row.Add(CommonRead.ReadStrL());
}
// 答えの.数
var equal = hwk[2];
Console.WriteLine(0);
}
}
public class D {
public void test() {
// 普通の数値
var n = CommonRead.ReadLong();
var a = CommonRead.ReadLongL().OrderByDescending(test => test).ToArray();
// 答えの数
var equal = 0L;
for (int count = 1; count < a.Count(); count++) {
equal += a[count - 1];
}
Console.WriteLine(equal);
}
}
static class CommonRead {
public static string ReadStr() { return Console.ReadLine(); }
public static string[] ReadStrA() { return ReadStr().Split(' '); }
public static List<string> ReadStrL() { return ReadStrA().ToList(); }
public static int ReadInt() { return Convert.ToInt32(ReadStr()); }
public static int[] ReadIntA() {
return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
}
public static List<int> ReadIntL() {
return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
}
public static long ReadLong() { return Convert.ToInt64(ReadStr()); }
public static long[] ReadLongA() {
return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
}
public static List<long> ReadLongL() {
return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
}
public static decimal ReadDecimal() { return Convert.ToDecimal(ReadStr()); }
public static decimal[] ReadDecimalA() {
return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
}
public static List<decimal> ReadDecimalL() {
return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
}
public static double ReadDouble() { return Convert.ToDouble(ReadStr()); }
public static double[] ReadDoubleA() {
return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
}
public static List<double> ReadDoubleL() {
return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public static void Main(string[] args) { new D().test(); }
}
public class A {
public void test() {
// 普通の数値
var yen = CommonRead.ReadInt();
if (yen % 1000 == 0) {
Console.WriteLine(0);
} else {
Console.WriteLine(1000 - yen % 1000);
}
}
}
public class B {
public void test() {
// 普通の数値
var yen = CommonRead.ReadInt();
var name = new List<string>();
name.Add("AC");
name.Add("WA");
name.Add("TLE");
name.Add("RE");
var AC = new List<string>();
// var WA = new List<string>();
// var TLE = new List<string>();
// var RE = new List<string>();
// 繰り返し回数
for (int count = 0; count < yen; count++) {
AC.Add(CommonRead.ReadStr());
}
foreach (string sn in name) {
Console.WriteLine(sn + " x " + AC.Count(str => str == sn));
}
}
}
public class C {
public void test() {
// 普通の数値
var hwk = CommonRead.ReadIntL();
var row = new List<List<string>>();
for (int count = 0; count < hwk[0]; count++) {
row.Add(CommonRead.ReadStrL());
}
// 答えの.数
var equal = hwk[2];
Console.WriteLine(0);
}
}
public class D {
public void test() {
// 普通の数値
var n = CommonRead.ReadLong();
var a = CommonRead.ReadLongL().OrderByDescending(x => x).ToList();
/*
//.GroupBy(x => x).Select(x => new { key = x.Key, count = x.Count() });
// 繰り返し
long exec = 0;
bool zenkai = false;
for (int i = 1; i<n; i++)
{
if (zenkai)
{
exec += a[i - 2];
}
else
{
exec += a[i - 1];
}
if (a[i] == a[i-1])
{
zenkai = true;
}
// 答えの数
Console.WriteLine(exec);
}
*/
long ans = 0;
for (int i = 0; i < n - 1; ++i) {
ans += a[(i + 1) / 2];
}
Console.WriteLine(ans);
}
}
static class CommonRead {
public static string ReadStr() { return Console.ReadLine(); }
public static string[] ReadStrA() { return ReadStr().Split(' '); }
public static List<string> ReadStrL() { return ReadStrA().ToList(); }
public static int ReadInt() { return Convert.ToInt32(ReadStr()); }
public static int[] ReadIntA() {
return ReadStrA().Select(s => Convert.ToInt32(s)).ToArray();
}
public static List<int> ReadIntL() {
return ReadStrA().Select(s => Convert.ToInt32(s)).ToList();
}
public static long ReadLong() { return Convert.ToInt64(ReadStr()); }
public static long[] ReadLongA() {
return ReadStrA().Select(s => Convert.ToInt64(s)).ToArray();
}
public static List<long> ReadLongL() {
return ReadStrA().Select(s => Convert.ToInt64(s)).ToList();
}
public static decimal ReadDecimal() { return Convert.ToDecimal(ReadStr()); }
public static decimal[] ReadDecimalA() {
return ReadStrA().Select(s => Convert.ToDecimal(s)).ToArray();
}
public static List<decimal> ReadDecimalL() {
return ReadStrA().Select(s => Convert.ToDecimal(s)).ToList();
}
public static double ReadDouble() { return Convert.ToDouble(ReadStr()); }
public static double[] ReadDoubleA() {
return ReadStrA().Select(s => Convert.ToDouble(s)).ToArray();
}
public static List<double> ReadDoubleL() {
return ReadStrA().Select(s => Convert.ToDouble(s)).ToList();
}
}
|
[["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 205, 22], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["-", 0, 7, 15, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 7, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 85], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 793
| 40
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ABC {
class ABC173D {
const string FILE = "/tmp/data.txt";
static void Main(string[] args) {
#if DEBUG
Console.SetIn(new StreamReader(FILE));
#endif
var N = RI();
var Ia = RIa(N);
Array.Sort(Ia);
var Ias = Ia.Reverse().ToArray();
long result = 0; // A0
// A1
result += Ias[0];
// A2
result += Ias[1];
// A3 以降は2つまえ
for (int i = 3; i < N; ++i) {
result += Ias[i - 2];
}
Console.WriteLine(result);
#if DEBUG
Console.WriteLine("*** end ***");
Console.SetIn(Console.In);
Console.ReadKey();
Console.WriteLine();
#endif
}
static int RI() { return int.Parse(Console.ReadLine()); }
static int[] RIa(int n) {
string[] sa = Console.ReadLine().Split(' ');
int[] la = new int[n];
for (int i = 0; i < n; ++i) {
la[i] = int.Parse(sa[i]);
}
return la;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ABC {
class ABC173D {
const string FILE = "/tmp/data.txt";
static void Main(string[] args) {
#if DEBUG
Console.SetIn(new StreamReader(FILE));
#endif
var N = RI();
var Ia = RIa(N);
Array.Sort(Ia);
var Ias = Ia.Reverse().ToArray();
long result = 0; // A0
// A1
result += Ias[0];
int idx = 1;
for (int i = 2; i < N;) {
result += Ias[idx];
i += 1;
if (i == N) {
break;
}
result += Ias[idx];
i += 1;
idx += 1;
}
Console.WriteLine(result);
#if DEBUG
Console.WriteLine("*** end ***");
Console.SetIn(Console.In);
Console.ReadKey();
Console.WriteLine();
#endif
}
static int RI() { return int.Parse(Console.ReadLine()); }
static int[] RIa(int n) {
string[] sa = Console.ReadLine().Split(' ');
int[] la = new int[n];
for (int i = 0; i < n; ++i) {
la[i] = int.Parse(sa[i]);
}
return la;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 8, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 241, 0, 29], ["-", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["+", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70]]
| 8
| 293
| 43
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Numerics;
namespace ABC173.D {
using static Util;
using static Math;
struct Conf {
public int Value;
public int Count;
}
public class Solver : SolverBase {
public void Run() {
var N = ReadInt();
var AA = ReadIntArray();
Array.Sort(AA);
Array.Reverse(AA);
// DumpArray(AA);
long ans = 0;
var set = new Set<int>() { IsMultiSet = true };
for (int i = 0; i < N; i++) {
var v = AA[i];
if (0 < set.Count) {
var c = set.Items[0];
set.Remove(c);
ans += c;
set.Add(v);
set.Add(v);
} else {
set.Add(v);
}
}
WriteLine(ans);
}
#if !MYHOME
static void Main(string[] args) { new Solver().Run(); }
#endif
}
#region Set
/// <summary>
/// Set/MultiSet
/// <code>
/// // 降順 & 重複あり
/// var set = new Set<int>((l, r) => r - l) { IsMultiSet = true };
/// // 降順の場合 0番目=最大値
/// if (0 < set.Count)
/// var maxValue = set[0];
/// // MultiSetの場合でも削除されるのは1要素のみ
/// ※C++のmultiset.erase(x)とは異なる set.Remove(213);
/// </code>
///
/// struct を要素に使う場合はこんな感じ
/// <code>
/// var set = new Set<Child>((l, r) => {
/// if (l.Rate != r.Rate)
/// // 第1ソートキー: 降順
/// //return r.Rate.CompareTo(l.Rate);
/// return r.Rate - l.Rate; //
/// box化が発生しないのでこちらの方が速い?→殆ど変わらない
/// else
/// // 第2ソートキー: 昇順
/// //return l.Garden.CompareTo(r.Garden);
/// return l.Garden - r.Garden;
/// });
/// </code>
/// </summary>
public class Set<T> {
Node root;
readonly IComparer<T> comparer;
readonly Node nil;
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) {}
public bool Add(T v) { return insert(ref root, v); }
///< summary>
///当該値を1つ削除する
///※C++のmultisetのerase()は当該値をすべて削除するが、これは1つだけ削除するように実装している
///</summary>
public bool Remove(T v) { return remove(ref root, v); }
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);
}
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;
}
}
}
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;
}
}
}
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
public static class Util {
/// <summary>反転した新しいstringを返す</summary>
public static string ReverseStr(this string s) {
return new string(s.Reverse().ToArray());
}
public static int Gcd(int a, int b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public readonly static long MOD = 1000000007;
public static string JoinString<T>(IEnumerable<T> array) {
var sb = new StringBuilder();
foreach (var item in array) {
sb.Append(item);
sb.Append(", ");
}
return sb.ToString();
}
public static void InitArray<T>(T[] ary, T value) {
for (int i = 0; i < ary.Length; i++) {
ary[i] = value;
}
}
public static void InitDP2<T>(T[,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
dp[i, j] = value;
}
}
}
public static void InitDP3<T>(T[,,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
for (int k = 0; k < dp.GetLength(2); k++) {
dp[i, j, k] = value;
}
}
}
}
/// <summary>charでも対応可能なMax</summary>
public static T Max<T>(T a, T b)
where T : IComparable { return 0 <= a.CompareTo(b) ? a : b; }
/// <summary>3要素以上に対応するMax</summary>
public static T Max<T>(params T[] nums)
where T : IComparable {
if (nums.Length == 0)
return default(T);
T max = nums[0];
for (int i = 1; i < nums.Length; i++) {
max = max.CompareTo(nums[i]) > 0 ? max : nums[i];
}
return max;
}
/// <summary>charでも対応可能なMin</summary>
public static T Min<T>(T a, T b)
where T : IComparable { return 0 < a.CompareTo(b) ? b : a; }
/// <summary>3要素以上に対応するMin</summary>
public static T Min<T>(params T[] nums)
where T : IComparable {
if (nums.Length == 0)
return default(T);
T min = nums[0];
for (int i = 1; i < nums.Length; i++) {
min = min.CompareTo(nums[i]) < 0 ? min : nums[i];
}
return min;
}
///< summary>targetValueに一番近い値を返す</summary>
public static long Nearest(long targetValue, params long[] values) {
Debug.Assert(0 < values.Length);
long minDiff = long.MaxValue;
long ans = long.MaxValue;
foreach (var v in values) {
var diff = Math.Abs(v - targetValue);
if (ReplaceIfSmaller(ref minDiff, diff)) {
ans = v;
}
}
return ans;
}
/// <summary>
/// ソート済み配列 ary に同じ値の要素が含まれている?
/// ※ソート順は昇順/降順どちらでもよい
/// </summary>
public static bool HasDuplicateInSortedArray<T>(T[] ary)
where T : IComparable, IComparable<T> {
if (ary.Length <= 1)
return false;
var lastNum = ary[ary.Length - 1];
foreach (var n in ary) {
if (lastNum.CompareTo(n) == 0) {
return true;
} else {
lastNum = n;
}
}
return false;
}
///< summary>v が r より大きい場合、r に v
///< を代入し、trueを返す。それ以外(同値の場合を含む)は何もせずfalseを返す</summary>
public static bool ReplaceIfBigger<T>(ref T r, T v)
where T : IComparable {
if (r.CompareTo(v) < 0) {
r = v;
return true;
} else {
return false;
}
}
///< summary>v が r よりが小さい場合、r に v
///< を代入し、trueを返す。それ以外(同値の場合を含む)は何もせずfalseを返す</summary>
public static bool ReplaceIfSmaller<T>(ref T r, T v)
where T : IComparable {
if (0 < r.CompareTo(v)) {
r = v;
return true;
} else {
return false;
}
}
public static void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
/// <summary>
/// dic[key]にadderを加算する。keyが存在しなかった場合はdic[key]=adder
/// をセットする。
/// </summary>
public static void AddTo<TKey>(this Dictionary<TKey, int> dic, TKey key,
int adder) {
if (dic.ContainsKey(key)) {
dic[key] += adder;
} else {
dic[key] = adder;
}
}
/// <summary>
/// 文字列 s が chars に含まれる文字を含んでいるか?
/// </summary>
public static bool ContainsAny(this string s, char[] chars) {
for (int j = 0; j < s.Length; j++) {
if (chars.Contains(s[j]))
return true;
}
return false;
}
/// <summary>
/// 二分探索
/// ※条件を満たす最小のidxを返す
/// ※満たすものがない場合は ary.Length を返す
/// ※『aryの先頭側が条件を満たさない、末尾側が条件を満たす』という前提
/// ただし、IsOK(...)の戻り値を逆転させれば、逆でも同じことが可能。
/// </summary>
/// <param name="ary">探索対象配列 ★ソート済みであること</param>
/// <param name="key">探索値
/// ※これ以上の値を持つ(IsOKがtrueを返す)最小のindexを返す</param>
public static int BinarySearch<T>(T[] ary, T key)
where T : IComparable, IComparable<T> {
int left = -1;
int right = ary.Length;
while (1 < right - left) {
var mid = left + (right - left) / 2;
if (IsOK(ary, mid, key)) {
right = mid;
} else {
left = mid;
}
}
// left は条件を満たさない最大の値、right
// は条件を満たす最小の値になっている
return right;
}
public static bool IsOK<T>(T[] ary, int idx, T key)
where T : IComparable, IComparable<T> {
// key <= ary[idx] と同じ意味
return key.CompareTo(ary[idx]) <= 0;
}
/// <summary>
/// nの 2進数における下からd(0-indexed)桁目のbitが立っている?
/// </summary>
public static int GetBit(long n, int d) {
if (0 == (n & (1L << d)))
return 0;
else
return 1;
}
}
public class SolverBase {
virtual protected string ReadLine() => Console.ReadLine();
virtual protected string ReadString() => ReadLine();
virtual protected int ReadInt() => int.Parse(ReadLine());
virtual protected long ReadLong() => long.Parse(ReadLine());
virtual protected string[] ReadStringArray() => ReadLine().Split(' ');
virtual protected void ReadString2(out string a, out string b) {
var ary = ReadStringArray();
a = ary[0];
b = ary[1];
}
virtual protected void ReadString3(out string a, out string b,
out string c) {
var ary = ReadStringArray();
a = ary[0];
b = ary[1];
c = ary[2];
}
virtual protected char[] ReadCharArray() => ReadLine()
.Split(' ')
.Select<string, char>(
s => s[0])
.ToArray();
virtual protected int[] ReadIntArray() => ReadLine()
.Split(' ')
.Select<string, int>(
s => int.Parse(s))
.ToArray();
virtual protected void ReadInt2(out int a, out int b) {
var ary = ReadIntArray();
a = ary[0];
b = ary[1];
}
virtual protected void ReadInt3(out int a, out int b, out int c) {
var ary = ReadIntArray();
a = ary[0];
b = ary[1];
c = ary[2];
}
virtual protected void ReadInt4(out int a, out int b, out int c,
out int d) {
var ary = ReadIntArray();
a = ary[0];
b = ary[1];
c = ary[2];
d = ary[3];
}
virtual protected long[] ReadLongArray() => ReadLine()
.Split(' ')
.Select<string, long>(
s => long.Parse(s))
.ToArray();
virtual protected void ReadLong2(out long a, out long b) {
var ary = ReadLongArray();
a = ary[0];
b = ary[1];
}
virtual protected void ReadLong3(out long a, out long b, out long c) {
var ary = ReadLongArray();
a = ary[0];
b = ary[1];
c = ary[2];
}
virtual protected void ReadLong4(out long a, out long b, out long c,
out long d) {
var ary = ReadLongArray();
a = ary[0];
b = ary[1];
c = ary[2];
d = ary[3];
}
virtual protected double[] ReadDoubleArray() => ReadLine()
.Split(' ')
.Select<string, double>(
s =>
double.Parse(s))
.ToArray();
virtual protected void WriteLine(string line) => Console.WriteLine(line);
virtual protected void WriteLine(double d) => Console.WriteLine($"{d:F9}");
virtual protected void WriteLine<T>(T value)
where T : IFormattable => Console.WriteLine(value); virtual protected void WriteGrid(IEnumerable<IEnumerable<char>> arrayOfArray) {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
foreach (var c in a) {
sb.Append(c);
}
sb.AppendLine();
}
WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void Dump(double d) => Console.WriteLine($"{d:F9}");
[Conditional("DEBUG")]
protected void Dump<T>(T x) => Console.WriteLine(x);
[Conditional("DEBUG")]
protected void DumpArray<T>(IEnumerable<T> array) {
string s = Util.JoinString(array);
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(s);
//_writer.WriteLine(s);
}
[Conditional("DEBUG")]
protected void DumpGrid(IEnumerable<IEnumerable<char>> arrayOfArray) {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
foreach (var c in a) {
sb.Append(c);
}
sb.AppendLine();
}
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(sb.ToString());
//_writer.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpGrid<T>(IEnumerable<IEnumerable<T>> arrayOfArray) {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
sb.AppendLine(Util.JoinString(a));
}
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(sb.ToString());
//_writer.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpGrid(bool[,] grid) {
var sb = new StringBuilder();
for (int i = 0; i < grid.GetLength(0); i++) {
for (int j = 0; j < grid.GetLength(1); j++) {
sb.Append(grid[i, j] ? "x " : ". ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpGrid(char[,] grid) {
var sb = new StringBuilder();
for (int i = 0; i < grid.GetLength(0); i++) {
for (int j = 0; j < grid.GetLength(1); j++) {
sb.Append(grid[i, j]);
sb.Append(" ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpDP<T>(T[,] dp)
where T : IFormattable {
var sb = new StringBuilder();
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
sb.Append(dp[i, j]);
sb.Append(", ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpDP3_Keta<T>(T[,,] dp)
where T : IFormattable {
var sb = new StringBuilder();
for (int i = 0; i < dp.GetLength(0); i++) {
sb.Append($"{i,2}: ");
for (int j = 0; j < dp.GetLength(1); j++) {
sb.Append($"{dp[i, j, 0]}-{dp[i, j, 1]}");
sb.Append(", ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Numerics;
namespace ABC173.D {
using static Util;
using static Math;
struct Conf {
public int Value;
public int Count;
}
public class Solver : SolverBase {
public void Run() {
var N = ReadInt();
var AA = ReadIntArray();
Array.Sort(AA);
Array.Reverse(AA);
// DumpArray(AA);
long ans = 0;
Queue<int> set = new Queue<int>(N + 1);
// var set = new Set<int>() { IsMultiSet = true };
for (int i = 0; i < N; i++) {
var v = AA[i];
if (0 < set.Count) {
var c = set.Dequeue();
ans += c;
set.Enqueue(v);
set.Enqueue(v);
} else {
set.Enqueue(v);
}
}
WriteLine(ans);
}
#if !MYHOME
static void Main(string[] args) { new Solver().Run(); }
#endif
}
#region Set
/// <summary>
/// Set/MultiSet
/// <code>
/// // 降順 & 重複あり
/// var set = new Set<int>((l, r) => r - l) { IsMultiSet = true };
/// // 降順の場合 0番目=最大値
/// if (0 < set.Count)
/// var maxValue = set[0];
/// // MultiSetの場合でも削除されるのは1要素のみ
/// ※C++のmultiset.erase(x)とは異なる set.Remove(213);
/// </code>
///
/// struct を要素に使う場合はこんな感じ
/// <code>
/// var set = new Set<Child>((l, r) => {
/// if (l.Rate != r.Rate)
/// // 第1ソートキー: 降順
/// //return r.Rate.CompareTo(l.Rate);
/// return r.Rate - l.Rate; //
/// box化が発生しないのでこちらの方が速い?→殆ど変わらない
/// else
/// // 第2ソートキー: 昇順
/// //return l.Garden.CompareTo(r.Garden);
/// return l.Garden - r.Garden;
/// });
/// </code>
/// </summary>
public class Set<T> {
Node root;
readonly IComparer<T> comparer;
readonly Node nil;
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) {}
public bool Add(T v) { return insert(ref root, v); }
///< summary>
///当該値を1つ削除する
///※C++のmultisetのerase()は当該値をすべて削除するが、これは1つだけ削除するように実装している
///</summary>
public bool Remove(T v) { return remove(ref root, v); }
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);
}
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;
}
}
}
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;
}
}
}
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
public static class Util {
/// <summary>反転した新しいstringを返す</summary>
public static string ReverseStr(this string s) {
return new string(s.Reverse().ToArray());
}
public static int Gcd(int a, int b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public readonly static long MOD = 1000000007;
public static string JoinString<T>(IEnumerable<T> array) {
var sb = new StringBuilder();
foreach (var item in array) {
sb.Append(item);
sb.Append(", ");
}
return sb.ToString();
}
public static void InitArray<T>(T[] ary, T value) {
for (int i = 0; i < ary.Length; i++) {
ary[i] = value;
}
}
public static void InitDP2<T>(T[,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
dp[i, j] = value;
}
}
}
public static void InitDP3<T>(T[,,] dp, T value) {
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
for (int k = 0; k < dp.GetLength(2); k++) {
dp[i, j, k] = value;
}
}
}
}
/// <summary>charでも対応可能なMax</summary>
public static T Max<T>(T a, T b)
where T : IComparable { return 0 <= a.CompareTo(b) ? a : b; }
/// <summary>3要素以上に対応するMax</summary>
public static T Max<T>(params T[] nums)
where T : IComparable {
if (nums.Length == 0)
return default(T);
T max = nums[0];
for (int i = 1; i < nums.Length; i++) {
max = max.CompareTo(nums[i]) > 0 ? max : nums[i];
}
return max;
}
/// <summary>charでも対応可能なMin</summary>
public static T Min<T>(T a, T b)
where T : IComparable { return 0 < a.CompareTo(b) ? b : a; }
/// <summary>3要素以上に対応するMin</summary>
public static T Min<T>(params T[] nums)
where T : IComparable {
if (nums.Length == 0)
return default(T);
T min = nums[0];
for (int i = 1; i < nums.Length; i++) {
min = min.CompareTo(nums[i]) < 0 ? min : nums[i];
}
return min;
}
///< summary>targetValueに一番近い値を返す</summary>
public static long Nearest(long targetValue, params long[] values) {
Debug.Assert(0 < values.Length);
long minDiff = long.MaxValue;
long ans = long.MaxValue;
foreach (var v in values) {
var diff = Math.Abs(v - targetValue);
if (ReplaceIfSmaller(ref minDiff, diff)) {
ans = v;
}
}
return ans;
}
/// <summary>
/// ソート済み配列 ary に同じ値の要素が含まれている?
/// ※ソート順は昇順/降順どちらでもよい
/// </summary>
public static bool HasDuplicateInSortedArray<T>(T[] ary)
where T : IComparable, IComparable<T> {
if (ary.Length <= 1)
return false;
var lastNum = ary[ary.Length - 1];
foreach (var n in ary) {
if (lastNum.CompareTo(n) == 0) {
return true;
} else {
lastNum = n;
}
}
return false;
}
///< summary>v が r より大きい場合、r に v
///< を代入し、trueを返す。それ以外(同値の場合を含む)は何もせずfalseを返す</summary>
public static bool ReplaceIfBigger<T>(ref T r, T v)
where T : IComparable {
if (r.CompareTo(v) < 0) {
r = v;
return true;
} else {
return false;
}
}
///< summary>v が r よりが小さい場合、r に v
///< を代入し、trueを返す。それ以外(同値の場合を含む)は何もせずfalseを返す</summary>
public static bool ReplaceIfSmaller<T>(ref T r, T v)
where T : IComparable {
if (0 < r.CompareTo(v)) {
r = v;
return true;
} else {
return false;
}
}
public static void Swap<T>(ref T a, ref T b) {
var tmp = a;
a = b;
b = tmp;
}
/// <summary>
/// dic[key]にadderを加算する。keyが存在しなかった場合はdic[key]=adder
/// をセットする。
/// </summary>
public static void AddTo<TKey>(this Dictionary<TKey, int> dic, TKey key,
int adder) {
if (dic.ContainsKey(key)) {
dic[key] += adder;
} else {
dic[key] = adder;
}
}
/// <summary>
/// 文字列 s が chars に含まれる文字を含んでいるか?
/// </summary>
public static bool ContainsAny(this string s, char[] chars) {
for (int j = 0; j < s.Length; j++) {
if (chars.Contains(s[j]))
return true;
}
return false;
}
/// <summary>
/// 二分探索
/// ※条件を満たす最小のidxを返す
/// ※満たすものがない場合は ary.Length を返す
/// ※『aryの先頭側が条件を満たさない、末尾側が条件を満たす』という前提
/// ただし、IsOK(...)の戻り値を逆転させれば、逆でも同じことが可能。
/// </summary>
/// <param name="ary">探索対象配列 ★ソート済みであること</param>
/// <param name="key">探索値
/// ※これ以上の値を持つ(IsOKがtrueを返す)最小のindexを返す</param>
public static int BinarySearch<T>(T[] ary, T key)
where T : IComparable, IComparable<T> {
int left = -1;
int right = ary.Length;
while (1 < right - left) {
var mid = left + (right - left) / 2;
if (IsOK(ary, mid, key)) {
right = mid;
} else {
left = mid;
}
}
// left は条件を満たさない最大の値、right
// は条件を満たす最小の値になっている
return right;
}
public static bool IsOK<T>(T[] ary, int idx, T key)
where T : IComparable, IComparable<T> {
// key <= ary[idx] と同じ意味
return key.CompareTo(ary[idx]) <= 0;
}
/// <summary>
/// nの 2進数における下からd(0-indexed)桁目のbitが立っている?
/// </summary>
public static int GetBit(long n, int d) {
if (0 == (n & (1L << d)))
return 0;
else
return 1;
}
}
public class SolverBase {
virtual protected string ReadLine() => Console.ReadLine();
virtual protected string ReadString() => ReadLine();
virtual protected int ReadInt() => int.Parse(ReadLine());
virtual protected long ReadLong() => long.Parse(ReadLine());
virtual protected string[] ReadStringArray() => ReadLine().Split(' ');
virtual protected void ReadString2(out string a, out string b) {
var ary = ReadStringArray();
a = ary[0];
b = ary[1];
}
virtual protected void ReadString3(out string a, out string b,
out string c) {
var ary = ReadStringArray();
a = ary[0];
b = ary[1];
c = ary[2];
}
virtual protected char[] ReadCharArray() => ReadLine()
.Split(' ')
.Select<string, char>(
s => s[0])
.ToArray();
virtual protected int[] ReadIntArray() => ReadLine()
.Split(' ')
.Select<string, int>(
s => int.Parse(s))
.ToArray();
virtual protected void ReadInt2(out int a, out int b) {
var ary = ReadIntArray();
a = ary[0];
b = ary[1];
}
virtual protected void ReadInt3(out int a, out int b, out int c) {
var ary = ReadIntArray();
a = ary[0];
b = ary[1];
c = ary[2];
}
virtual protected void ReadInt4(out int a, out int b, out int c,
out int d) {
var ary = ReadIntArray();
a = ary[0];
b = ary[1];
c = ary[2];
d = ary[3];
}
virtual protected long[] ReadLongArray() => ReadLine()
.Split(' ')
.Select<string, long>(
s => long.Parse(s))
.ToArray();
virtual protected void ReadLong2(out long a, out long b) {
var ary = ReadLongArray();
a = ary[0];
b = ary[1];
}
virtual protected void ReadLong3(out long a, out long b, out long c) {
var ary = ReadLongArray();
a = ary[0];
b = ary[1];
c = ary[2];
}
virtual protected void ReadLong4(out long a, out long b, out long c,
out long d) {
var ary = ReadLongArray();
a = ary[0];
b = ary[1];
c = ary[2];
d = ary[3];
}
virtual protected double[] ReadDoubleArray() => ReadLine()
.Split(' ')
.Select<string, double>(
s =>
double.Parse(s))
.ToArray();
virtual protected void WriteLine(string line) => Console.WriteLine(line);
virtual protected void WriteLine(double d) => Console.WriteLine($"{d:F9}");
virtual protected void WriteLine<T>(T value)
where T : IFormattable => Console.WriteLine(value); virtual protected void WriteGrid(IEnumerable<IEnumerable<char>> arrayOfArray) {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
foreach (var c in a) {
sb.Append(c);
}
sb.AppendLine();
}
WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void Dump(double d) => Console.WriteLine($"{d:F9}");
[Conditional("DEBUG")]
protected void Dump<T>(T x) => Console.WriteLine(x);
[Conditional("DEBUG")]
protected void DumpArray<T>(IEnumerable<T> array) {
string s = Util.JoinString(array);
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(s);
//_writer.WriteLine(s);
}
[Conditional("DEBUG")]
protected void DumpGrid(IEnumerable<IEnumerable<char>> arrayOfArray) {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
foreach (var c in a) {
sb.Append(c);
}
sb.AppendLine();
}
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(sb.ToString());
//_writer.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpGrid<T>(IEnumerable<IEnumerable<T>> arrayOfArray) {
var sb = new StringBuilder();
foreach (var a in arrayOfArray) {
sb.AppendLine(Util.JoinString(a));
}
// Consoleに出力すると、UnitTestの邪魔をしないというメリットあり。
Console.WriteLine(sb.ToString());
//_writer.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpGrid(bool[,] grid) {
var sb = new StringBuilder();
for (int i = 0; i < grid.GetLength(0); i++) {
for (int j = 0; j < grid.GetLength(1); j++) {
sb.Append(grid[i, j] ? "x " : ". ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpGrid(char[,] grid) {
var sb = new StringBuilder();
for (int i = 0; i < grid.GetLength(0); i++) {
for (int j = 0; j < grid.GetLength(1); j++) {
sb.Append(grid[i, j]);
sb.Append(" ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpDP<T>(T[,] dp)
where T : IFormattable {
var sb = new StringBuilder();
for (int i = 0; i < dp.GetLength(0); i++) {
for (int j = 0; j < dp.GetLength(1); j++) {
sb.Append(dp[i, j]);
sb.Append(", ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
[Conditional("DEBUG")]
protected void DumpDP3_Keta<T>(T[,,] dp)
where T : IFormattable {
var sb = new StringBuilder();
for (int i = 0; i < dp.GetLength(0); i++) {
sb.Append($"{i,2}: ");
for (int j = 0; j < dp.GetLength(1); j++) {
sb.Append($"{dp[i, j, 0]}-{dp[i, j, 1]}");
sb.Append(", ");
}
sb.AppendLine();
}
Console.WriteLine(sb.ToString());
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 39, 236, 141, 22], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 18], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 47], ["-", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 230, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 230, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 230, 3, 4, 0, 28, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 45], ["-", 0, 212, 0, 230, 10, 229, 0, 11, 31, 22], ["-", 0, 230, 10, 229, 0, 11, 0, 202, 0, 32], ["-", 0, 230, 10, 229, 0, 11, 12, 211, 0, 146], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 46], ["-", 0, 200, 0, 212, 0, 204, 205, 214, 141, 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], ["-", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22]]
| 8
| 4,211
| 31
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextLong();
long[] a = sc.LongArray();
a = a.OrderByDescending(num => num).ToArray();
long answer = 0;
long a1 = 0;
long a2 = 0;
for (int i = 0; i < n; i++) {
if (i == 0) {
a1 = a[i];
a2 = a[i];
continue;
}
answer += a2;
a1 = a2;
a2 = a[i];
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextLong();
long[] a = sc.LongArray();
a = a.OrderByDescending(num => num).ToArray();
long answer = 0;
for (int i = 0; i < n; i++) {
if (i == 0) {
continue;
}
answer += a[i / 2];
}
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, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 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, 32], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 85], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 446
| 34
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Extensions;
using DSA;
using static System.Math;
using static Extensions.MathExtension;
using static Extensions.ConsoleInputExtension;
using static Extensions.ConsoleOutputExtension;
class Solver {
public void Solve() {
// Solve Code Here
int n = Cin;
var a = new long[n];
for (int i = 0; i < n; i++)
a[i] = Cin;
a = a.OrderByDescending(val => val).ToArray();
if (n == 1) {
Coutln(0);
return;
}
if (n == 2) {
Coutln(a[0]);
return;
}
if (n == 3) {
Coutln(a[0] + a[1]);
return;
}
long sum = a[0] + a[1];
for (int i = 3; i < n; i++)
sum += a[i - 2];
Coutln(sum);
}
}
// Other Classes Here
#if !DEBUG
class EntryPoint {
static void Main(string[] args) {
new Solver().Solve();
Flush();
}
}
#endif
namespace DSA {
public class PriorityQueue<T> {
private readonly List<Tuple<int, T>> _list = new List<Tuple<int, T>>();
public int Count => _list.Count;
public PriorityQueue() {}
public void Push(T item, int priority) {
_list.Add(Tuple.Create(priority, item));
int itemIndex = Count - 1, parentIndex;
while ((parentIndex = GetParentIndex(itemIndex)) != -1 &&
priority > _list[parentIndex].Item1) {
Swap(itemIndex, parentIndex);
itemIndex = parentIndex;
}
}
private int GetParentIndex(int index) {
if (index == 0)
return -1;
return ((index + 1) >> 1) - 1;
}
private Tuple<int, int> GetChildrenIndex(int index) {
var item2 = (index + 1) << 1;
var item1 = item2 - 1;
return Tuple.Create(item1, item2);
}
public T Pop() {
if (Count <= 0)
throw new IndexOutOfRangeException();
var item = _list[0].Item2;
_list[0] = _list[Count - 1];
_list.RemoveAt(Count - 1);
int index = 0;
Tuple<int, int> childrenIndex = GetChildrenIndex(index);
while (childrenIndex.Item1 < Count || childrenIndex.Item2 < Count) {
if (childrenIndex.Item2 >= Count ||
_list[childrenIndex.Item1].Item1 > _list[childrenIndex.Item2].Item1) {
if (_list[childrenIndex.Item1].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item1);
index = childrenIndex.Item1;
} else {
if (_list[childrenIndex.Item2].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item2);
index = childrenIndex.Item2;
}
childrenIndex = GetChildrenIndex(index);
}
return item;
}
public T Peek() { return _list[0].Item2; }
private void Swap(int index1, int index2) {
var tmp = _list[index1];
_list[index1] = _list[index2];
_list[index2] = tmp;
}
}
public class UnionFind {
private readonly int[] _array;
public UnionFind(int size) {
_array = new int[size];
for (int i = 0; i < size; i++) {
_array[i] = i;
}
}
public int GetRootNode(int n) {
if (_array[n] == n)
return n;
return _array[n] = GetRootNode(_array[n]);
}
public void UnionGroup(int a, int b) {
var rootA = GetRootNode(a);
var rootB = GetRootNode(b);
if (rootA == rootB)
return;
_array[rootA] = rootB;
}
public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b);
public bool IsRoot(int n) => _array[n] == n;
}
public delegate T SegTreeCombiner<T>(T item1, T item2);
public class SegTree<T> {
private readonly T _defaultItem;
private readonly SegTreeCombiner<T> _func;
private T[] List;
private int size;
public SegTree(T[] list, T defaultItem, SegTreeCombiner<T> func) {
_defaultItem = defaultItem;
_func = func;
size = 1;
while (size < list.Length)
size <<= 1;
List = new T[2 * size - 1];
for (int i = 0; i < list.Length; i++)
List[i + size - 1] = list[i];
for (int i = list.Length; i < size; i++)
List[i + size - 1] = defaultItem;
for (int i = size - 1 - 1; i >= 0; i--) {
List[i] = _func(List[2 * i + 1], List[2 * i + 2]);
}
}
public void Update(int index, T value) {
index += size - 1;
List[index] = value;
while (index > 0) {
index = (index - 1) >> 1;
List[index] = _func(List[2 * index + 1], List[2 * index + 2]);
}
}
public T Query(int a, int b) { return Query(a, b, 0, 0, size); }
private T Query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return _defaultItem;
if (a <= l && r <= b)
return List[k];
return _func(Query(a, b, k * 2 + 1, l, (l + r) >> 1),
Query(a, b, k * 2 + 2, (l + r) >> 1, r));
}
}
public static class BinarySearch {
public delegate bool Terms<T>(T i);
public static int UpperBound(int initLeft, int initRight, Terms<int> term) {
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static long UpperBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static int LowerBound(int initLeft, int initRight, Terms<int> term) {
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initRight && term(mid))
right = mid;
else
left = mid;
}
return right;
}
public static long LowerBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (term(mid))
right = mid;
else
left = mid;
}
return right;
}
}
}
struct ModInt {
public long Value { get; }
public static long Mod { get; set; } = 1000000000L + 7;
public ModInt(long l) {
long value = l % Mod;
while (value < 0)
value += Mod;
Value = value % Mod;
}
public static implicit operator long(ModInt m) { return m.Value; }
public static implicit operator ModInt(long l) { return new ModInt(l); }
public static ModInt operator +(ModInt a, ModInt b) {
return new ModInt(a.Value + b.Value);
}
public static ModInt operator -(ModInt a, ModInt b) {
return new ModInt(a.Value - b.Value);
}
public static ModInt operator *(ModInt a, ModInt b) {
return new ModInt(a.Value * b.Value);
}
public static ModInt operator /(ModInt a, ModInt b) {
return new ModInt(a * b.Inverse());
}
public override string ToString() { return Value.ToString(); }
}
static class ModIntMath {
public static ModInt Pow(this ModInt a, ModInt b) {
var pow = b.Value;
var m = a;
ModInt ans = new ModInt(1);
while (pow != 0) {
if ((pow & 1) == 1) {
ans *= m;
}
pow >>= 1;
m *= m;
}
return ans;
}
public static ModInt Inverse(this ModInt m) {
return m.Pow((ModInt)(ModInt.Mod - 2));
}
}
namespace Extensions {
public class ConsoleInputExtension {
private static readonly ConsoleInputExtension _cin =
new ConsoleInputExtension();
public static ConsoleInputExtension Cin => _cin;
private static readonly Queue<string> _inputQueue = new Queue<string>();
private ConsoleInputExtension() {}
public static implicit operator string(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return _inputQueue.Dequeue();
}
public static implicit operator int(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return int.Parse(_inputQueue.Dequeue());
}
public static implicit operator long(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return long.Parse(_inputQueue.Dequeue());
}
public static implicit operator float(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return float.Parse(_inputQueue.Dequeue());
}
public static implicit operator double(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return double.Parse(_inputQueue.Dequeue());
}
}
public static class ConsoleOutputExtension {
private static StringBuilder _builder = new StringBuilder();
public static void Cout(object o) { _builder.Append(o); }
public static void CoutF(object o) {
_builder.Append(o);
Flush();
}
public static void Coutln(object o) {
_builder.Append(o);
_builder.Append('\n');
}
public static void Coutln() { _builder.Append('\n'); }
public static void CoutlnF(object o) {
_builder.Append(o);
_builder.Append('\n');
Flush();
}
public static void Flush() {
Console.Write(_builder.ToString());
_builder.Clear();
}
}
public static class MathExtension {
//最小公倍数
public static int LCM(int num1, int num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
public static long LCM(long num1, long num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
//最大公約数
public static int GCD(int num1, int num2) {
int a = Math.Max(num1, num2);
int b = Math.Min(num1, num2);
if (b == 0)
return a;
int mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
public static long GCD(long num1, long num2) {
long a = Math.Max(num1, num2);
long b = Math.Min(num1, num2);
if (b == 0)
return a;
long mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
}
public static class EnumerableExtension {
public delegate void Function<in T>(T val);
public static void ForEach<T>(this IEnumerable<T> enumerable,
Function<T> function) {
foreach (var x in enumerable) {
function(x);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Extensions;
using DSA;
using static System.Math;
using static Extensions.MathExtension;
using static Extensions.ConsoleInputExtension;
using static Extensions.ConsoleOutputExtension;
class Solver {
public void Solve() {
// Solve Code Here
int n = Cin;
var a = new long[n];
for (int i = 0; i < n; i++)
a[i] = Cin;
a = a.OrderByDescending(val => val).ToArray();
if (n == 1) {
Coutln(0);
return;
}
if (n == 2) {
Coutln(a[0]);
return;
}
if (n == 3) {
Coutln(a[0] + a[1]);
return;
}
long sum = 0;
for (int i = 0; i < n - 1; i++) {
sum += a[(i + 1) >> 1];
}
Coutln(sum);
}
}
// Other Classes Here
#if !DEBUG
class EntryPoint {
static void Main(string[] args) {
new Solver().Solve();
Flush();
}
}
#endif
namespace DSA {
public class PriorityQueue<T> {
private readonly List<Tuple<int, T>> _list = new List<Tuple<int, T>>();
public int Count => _list.Count;
public PriorityQueue() {}
public void Push(T item, int priority) {
_list.Add(Tuple.Create(priority, item));
int itemIndex = Count - 1, parentIndex;
while ((parentIndex = GetParentIndex(itemIndex)) != -1 &&
priority > _list[parentIndex].Item1) {
Swap(itemIndex, parentIndex);
itemIndex = parentIndex;
}
}
private int GetParentIndex(int index) {
if (index == 0)
return -1;
return ((index + 1) >> 1) - 1;
}
private Tuple<int, int> GetChildrenIndex(int index) {
var item2 = (index + 1) << 1;
var item1 = item2 - 1;
return Tuple.Create(item1, item2);
}
public T Pop() {
if (Count <= 0)
throw new IndexOutOfRangeException();
var item = _list[0].Item2;
_list[0] = _list[Count - 1];
_list.RemoveAt(Count - 1);
int index = 0;
Tuple<int, int> childrenIndex = GetChildrenIndex(index);
while (childrenIndex.Item1 < Count || childrenIndex.Item2 < Count) {
if (childrenIndex.Item2 >= Count ||
_list[childrenIndex.Item1].Item1 > _list[childrenIndex.Item2].Item1) {
if (_list[childrenIndex.Item1].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item1);
index = childrenIndex.Item1;
} else {
if (_list[childrenIndex.Item2].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item2);
index = childrenIndex.Item2;
}
childrenIndex = GetChildrenIndex(index);
}
return item;
}
public T Peek() { return _list[0].Item2; }
private void Swap(int index1, int index2) {
var tmp = _list[index1];
_list[index1] = _list[index2];
_list[index2] = tmp;
}
}
public class UnionFind {
private readonly int[] _array;
public UnionFind(int size) {
_array = new int[size];
for (int i = 0; i < size; i++) {
_array[i] = i;
}
}
public int GetRootNode(int n) {
if (_array[n] == n)
return n;
return _array[n] = GetRootNode(_array[n]);
}
public void UnionGroup(int a, int b) {
var rootA = GetRootNode(a);
var rootB = GetRootNode(b);
if (rootA == rootB)
return;
_array[rootA] = rootB;
}
public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b);
public bool IsRoot(int n) => _array[n] == n;
}
public delegate T SegTreeCombiner<T>(T item1, T item2);
public class SegTree<T> {
private readonly T _defaultItem;
private readonly SegTreeCombiner<T> _func;
private T[] List;
private int size;
public SegTree(T[] list, T defaultItem, SegTreeCombiner<T> func) {
_defaultItem = defaultItem;
_func = func;
size = 1;
while (size < list.Length)
size <<= 1;
List = new T[2 * size - 1];
for (int i = 0; i < list.Length; i++)
List[i + size - 1] = list[i];
for (int i = list.Length; i < size; i++)
List[i + size - 1] = defaultItem;
for (int i = size - 1 - 1; i >= 0; i--) {
List[i] = _func(List[2 * i + 1], List[2 * i + 2]);
}
}
public void Update(int index, T value) {
index += size - 1;
List[index] = value;
while (index > 0) {
index = (index - 1) >> 1;
List[index] = _func(List[2 * index + 1], List[2 * index + 2]);
}
}
public T Query(int a, int b) { return Query(a, b, 0, 0, size); }
private T Query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return _defaultItem;
if (a <= l && r <= b)
return List[k];
return _func(Query(a, b, k * 2 + 1, l, (l + r) >> 1),
Query(a, b, k * 2 + 2, (l + r) >> 1, r));
}
}
public static class BinarySearch {
public delegate bool Terms<T>(T i);
public static int UpperBound(int initLeft, int initRight, Terms<int> term) {
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static long UpperBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static int LowerBound(int initLeft, int initRight, Terms<int> term) {
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initRight && term(mid))
right = mid;
else
left = mid;
}
return right;
}
public static long LowerBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (term(mid))
right = mid;
else
left = mid;
}
return right;
}
}
}
struct ModInt {
public long Value { get; }
public static long Mod { get; set; } = 1000000000L + 7;
public ModInt(long l) {
long value = l % Mod;
while (value < 0)
value += Mod;
Value = value % Mod;
}
public static implicit operator long(ModInt m) { return m.Value; }
public static implicit operator ModInt(long l) { return new ModInt(l); }
public static ModInt operator +(ModInt a, ModInt b) {
return new ModInt(a.Value + b.Value);
}
public static ModInt operator -(ModInt a, ModInt b) {
return new ModInt(a.Value - b.Value);
}
public static ModInt operator *(ModInt a, ModInt b) {
return new ModInt(a.Value * b.Value);
}
public static ModInt operator /(ModInt a, ModInt b) {
return new ModInt(a * b.Inverse());
}
public override string ToString() { return Value.ToString(); }
}
static class ModIntMath {
public static ModInt Pow(this ModInt a, ModInt b) {
var pow = b.Value;
var m = a;
ModInt ans = new ModInt(1);
while (pow != 0) {
if ((pow & 1) == 1) {
ans *= m;
}
pow >>= 1;
m *= m;
}
return ans;
}
public static ModInt Inverse(this ModInt m) {
return m.Pow((ModInt)(ModInt.Mod - 2));
}
}
namespace Extensions {
public class ConsoleInputExtension {
private static readonly ConsoleInputExtension _cin =
new ConsoleInputExtension();
public static ConsoleInputExtension Cin => _cin;
private static readonly Queue<string> _inputQueue = new Queue<string>();
private ConsoleInputExtension() {}
public static implicit operator string(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return _inputQueue.Dequeue();
}
public static implicit operator int(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return int.Parse(_inputQueue.Dequeue());
}
public static implicit operator long(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return long.Parse(_inputQueue.Dequeue());
}
public static implicit operator float(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return float.Parse(_inputQueue.Dequeue());
}
public static implicit operator double(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return double.Parse(_inputQueue.Dequeue());
}
}
public static class ConsoleOutputExtension {
private static StringBuilder _builder = new StringBuilder();
public static void Cout(object o) { _builder.Append(o); }
public static void CoutF(object o) {
_builder.Append(o);
Flush();
}
public static void Coutln(object o) {
_builder.Append(o);
_builder.Append('\n');
}
public static void Coutln() { _builder.Append('\n'); }
public static void CoutlnF(object o) {
_builder.Append(o);
_builder.Append('\n');
Flush();
}
public static void Flush() {
Console.Write(_builder.ToString());
_builder.Clear();
}
}
public static class MathExtension {
//最小公倍数
public static int LCM(int num1, int num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
public static long LCM(long num1, long num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
//最大公約数
public static int GCD(int num1, int num2) {
int a = Math.Max(num1, num2);
int b = Math.Min(num1, num2);
if (b == 0)
return a;
int mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
public static long GCD(long num1, long num2) {
long a = Math.Max(num1, num2);
long b = Math.Min(num1, num2);
if (b == 0)
return a;
long mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
}
public static class EnumerableExtension {
public delegate void Function<in T>(T val);
public static void ForEach<T>(this IEnumerable<T> enumerable,
Function<T> function) {
foreach (var x in enumerable) {
function(x);
}
}
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 204, 205, 22], ["-", 0, 212, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 212, 0, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 200, 0, 212, 0, 16, 12, 204, 205, 22], ["-", 0, 212, 0, 16, 12, 204, 206, 207, 0, 70], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 212, 0, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 206, 207, 0, 28, 0, 16, 31, 23, 0, 25], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 152], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 2,683
| 22
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder.Abc173 {
class E {
static long mod = 1000000007;
public static void Main() {
var nk =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var n = nk[0];
var k = nk[1];
long ans = 1;
var a =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
if (n == k) {
Console.WriteLine(a.Aggregate(1L, (acc, x) => acc * (mod + x) % mod));
return;
}
if (a.All(x => x <= 0)) {
if (k % 2 == 1)
a = a.OrderByDescending(x => x).ToArray();
else
a = a.OrderBy(x => Math.Abs(x)).ToArray();
Console.WriteLine(
a.Take(k).Aggregate(1L, (acc, x) => acc * (mod + x) % mod));
return;
}
a = a.OrderByDescending(x => Math.Abs(x)).ToArray();
bool positive = true;
int nlast = 0;
int plast = -1;
for (int i = 0; i < k; i++) {
if (a[i] < 0) {
positive = !positive;
nlast = i;
} else
plast = i;
}
if (positive) {
for (int i = 0; i < k; i++)
ans = ans * (a[i] > 0 ? a[i] : (mod + a[i])) % mod;
Console.WriteLine(ans);
return;
}
int nalt = -1;
for (int i = k; i < a.Length; i++) {
if (a[i] >= 0) {
nalt = i;
break;
}
}
int palt = -1;
for (int i = k; i < a.Length; i++) {
if (a[i] < 0) {
palt = i;
break;
}
}
if (plast >= 0 && palt >= 0) {
if (nlast >= 0 && nalt >= 0) {
if (a[palt] * a[nlast] > a[nalt] * a[plast])
ans = Prod(a, k, plast, palt);
else
ans = Prod(a, k, nlast, nalt);
} else
ans = Prod(a, k, plast, palt);
} else
ans = Prod(a, k, nlast, nalt);
Console.WriteLine(ans);
}
static long Prod(long[] a, int k, int skip, int alt) {
long ans = (mod + a[alt]) % mod;
for (int i = 0; i < k; i++)
if (i != skip)
ans = ans * (mod + a[i]) % mod;
return ans;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder.Abc173 {
class E {
static long mod = 1000000007;
public static void Main() {
var nk =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var n = nk[0];
var k = nk[1];
long ans = 1;
var a =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
if (n == k) {
Console.WriteLine(
a.Aggregate(1L, (acc, x) => acc = acc * (mod + x) % mod));
return;
}
if (a.All(x => x <= 0)) {
if (k % 2 == 1)
a = a.OrderByDescending(x => x).ToArray();
else
a = a.OrderByDescending(x => Math.Abs(x)).ToArray();
Console.WriteLine(
a.Take(k).Aggregate(1L, (acc, x) => acc = acc * (mod + x) % mod));
return;
}
a = a.OrderByDescending(x => Math.Abs(x)).ToArray();
bool positive = true;
int nlast = 0;
int plast = -1;
for (int i = 0; i < k; i++) {
if (a[i] < 0) {
positive = !positive;
nlast = i;
} else
plast = i;
}
// 上位K個の積が正なら
if (positive) {
for (int i = 0; i < k; i++)
ans = ans * (a[i] > 0 ? a[i] : (mod + a[i])) % mod;
Console.WriteLine(ans);
return;
}
int nalt = -1;
for (int i = k; i < a.Length; i++) {
if (a[i] >= 0) {
nalt = i;
break;
}
}
int palt = -1;
for (int i = k; i < a.Length; i++) {
if (a[i] < 0) {
palt = i;
break;
}
}
if (plast >= 0 && palt >= 0) {
if (nlast >= 0 && nalt >= 0) {
if (a[palt] * a[nlast] > a[nalt] * a[plast])
ans = Prod(a, k, plast, palt);
else
ans = Prod(a, k, nlast, nalt);
} else
ans = Prod(a, k, plast, palt);
} else if (nlast >= 0 && nalt >= 0)
ans = Prod(a, k, nlast, nalt);
else
ans = 0;
Console.WriteLine(ans);
}
static long Prod(long[] a, int k, int skip, int alt) {
long ans = (mod + a[alt]) % mod;
for (int i = 0; i < k; i++)
if (i != skip)
ans = ans * (mod + a[i]) % mod;
return ans;
}
}
}
|
[["+", 0, 28, 0, 218, 8, 11, 0, 202, 0, 32], ["+", 0, 218, 8, 11, 12, 16, 31, 16, 31, 22], ["-", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 11, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 20], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 20], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25], ["+", 8, 196, 0, 57, 75, 57, 64, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["+", 0, 57, 75, 57, 75, 1, 0, 11, 31, 22], ["+", 75, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 57, 75, 1, 0, 11, 12, 203]]
| 8
| 658
| 21
|
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 ProblemA {
static bool SAIKI = false;
static public int numberOfRandomCases = 1;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {
var input = File.ReadAllLines(
@"E:\MainDirectory\Programming\AtCoder\de\tester\example\sample2.in");
foreach (var iten in input) {
_input.Add(iten);
}
_outputChecker = ans => {
var output = new List<string>();
foreach (var item in ans) {
if (item == "")
continue;
output.Add(item);
}
File.WriteAllLines(
@"E:\MainDirectory\Programming\AtCoder\de\tester\example\sample2.out",
output);
return true;
};
}
static public void Solve() {
var D = NN;
var cList = NNList(26);
var sList = new long [D][];
for (var i = 0; i < D; i++) {
sList[i] = NNList(26);
}
var tList = NNList(D);
var ans = new long[D];
var maxScore = long.MinValue;
{
var ret = tList;
var thisScore = 0L;
var lastDay = new long[26];
for (var j = 0; j < D; j++) {
var selected = ret[j] - 1;
thisScore += sList[j][selected];
lastDay[selected] = j + 1;
for (var k = 0; k < 26; k++) {
thisScore -= cList[k] * (j + 1 - lastDay[k]);
}
}
if (maxScore < thisScore) {
maxScore = thisScore;
ans = ret;
}
Console.WriteLine(thisScore);
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return isEof; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIODebug() {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string Scan() => NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Long() => long.Parse(NextString());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override double Double() => double.Parse(NextString());
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class ProblemA {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {
var input = File.ReadAllLines(
@"E:\MainDirectory\Programming\AtCoder\de\tester\example\sample2.in");
foreach (var iten in input) {
_input.Add(iten);
}
_outputChecker = ans => {
var output = new List<string>();
foreach (var item in ans) {
if (item == "")
continue;
output.Add(item);
}
File.WriteAllLines(
@"E:\MainDirectory\Programming\AtCoder\de\tester\example\sample2.out",
output);
return true;
};
}
static public void Solve() {
var D = NN;
var cList = NNList(26);
var sList = new long [D][];
for (var i = 0; i < D; i++) {
sList[i] = NNList(26);
}
var tList = NNList(D);
{
var ret = tList;
var thisScore = 0L;
var lastDay = new long[26];
for (var j = 0; j < D; j++) {
var selected = ret[j] - 1;
thisScore += sList[j][selected];
lastDay[selected] = j + 1;
for (var k = 0; k < 26; k++) {
thisScore -= cList[k] * (j + 1 - lastDay[k]);
}
Console.WriteLine(thisScore);
}
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get { return isEof; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public LIB_FastIODebug() {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string Scan() => NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override long Long() => long.Parse(NextString());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override double Double() => double.Parse(NextString());
}
}
|
[["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 23, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 8, 196, 0, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 196, 0, 57, 0, 121], ["-", 0, 195, 8, 196, 0, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 196, 0, 57, 15, 16, 31, 22], ["-", 8, 196, 0, 196, 0, 57, 15, 16, 17, 18], ["-", 8, 196, 0, 196, 0, 57, 15, 16, 12, 22], ["-", 8, 196, 0, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 1,777
| 36
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
public class QuestionA {
public static void Main(string[] args) {
// 整数の入力
long a = long.Parse(Console.ReadLine());
Console.WriteLine(Math.Pow(a, 6));
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
public class QuestionA {
public static void Main(string[] args) {
// 整数の入力
long a = long.Parse(Console.ReadLine());
Console.WriteLine(a + Math.Pow(a, 2) + Math.Pow(a, 3));
Console.Out.Flush();
}
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 31, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 87
| 13
|
using System;
namespace AtCoder172 {
class ProgramA {
static void Main(string[] args) {
var input = Console.ReadLine();
var a = int.Parse(Console.ReadLine());
Console.WriteLine(a + a * a + a * a * a);
}
}
}
|
using System;
namespace AtCoder172 {
class ProgramA {
static void Main(string[] args) {
var a = int.Parse(Console.ReadLine());
Console.WriteLine(a + a * a + a * a * a);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217]]
| 8
| 62
| 9
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
internal class Program {
private static void Main(string[] args) {
var p = new ProbremA();
p.Run();
}
}
internal class ConsoleOutput {
public void Print<T>(T target) { Console.WriteLine(target.ToString()); }
public void PrintList<T>(IEnumerable<T> targets) {
var results = targets.Select(obj => obj.ToString());
Console.WriteLine(string.Join(" ", results));
}
}
internal class ConsoleInput {
private bool testMode = false;
private List<string> testInput = new List<string> {
"7 10",
"1",
};
#region Impl
public int GetInt() { return int.Parse(Get()); }
public List<int> GetIntList() {
return Get().Split(' ').Select(obj => int.Parse(obj)).ToList();
}
public string GetString() { return Get(); }
private string Get() {
if (testMode) {
var result = testInput[0];
testInput.RemoveAt(0);
return result;
}
return Console.ReadLine();
}
#endregion Impl
}
internal class ProbremA {
private ConsoleInput input = new ConsoleInput();
private ConsoleOutput output = new ConsoleOutput();
public void Run() {
int t = input.GetInt();
output.Print($"t {t * t} {t * t * t}");
}
}
/*
internal class ProbremA
{
private ConsoleInput input = new ConsoleInput();
private ConsoleOutput output = new ConsoleOutput();
public void Run()
{
}
}
*/
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
internal class Program {
private static void Main(string[] args) {
var p = new ProbremA();
p.Run();
}
}
internal class ConsoleOutput {
public void Print<T>(T target) { Console.WriteLine(target.ToString()); }
public void PrintList<T>(IEnumerable<T> targets) {
var results = targets.Select(obj => obj.ToString());
Console.WriteLine(string.Join(" ", results));
}
}
internal class ConsoleInput {
private bool testMode = false;
private List<string> testInput = new List<string> {
"10",
};
#region Impl
public int GetInt() { return int.Parse(Get()); }
public List<int> GetIntList() {
return Get().Split(' ').Select(obj => int.Parse(obj)).ToList();
}
public string GetString() { return Get(); }
private string Get() {
if (testMode) {
var result = testInput[0];
testInput.RemoveAt(0);
return result;
}
return Console.ReadLine();
}
#endregion Impl
}
internal class ProbremA {
private ConsoleInput input = new ConsoleInput();
private ConsoleOutput output = new ConsoleOutput();
public void Run() {
int t = input.GetInt();
int result = t + (t * t) + (t * t * t);
output.Print(result);
}
}
/*
internal class ProbremA
{
private ConsoleInput input = new ConsoleInput();
private ConsoleOutput output = new ConsoleOutput();
public void Run()
{
}
}
*/
}
|
[["-", 0, 212, 0, 230, 10, 229, 0, 5, 0, 222], ["-", 0, 212, 0, 230, 10, 229, 0, 5, 0, 62], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 21], ["+", 0, 212, 0, 230, 10, 229, 0, 5, 0, 222], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["+", 0, 212, 0, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 332
| 32
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;
namespace ConsoleApp2 {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<int> Slist() {
return new List<int>(ReadLine().Split().Select(int.Parse));
}
static void Main(string[] args) {
var X = Sarray()[0];
var tmp = 360.0 / X;
var ans = tmp;
while (ans != (long)ans) {
ans += tmp;
}
WriteLine(ans);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.Design;
using System.Globalization;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Schema;
using static System.Console;
namespace ConsoleApp2 {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<int> Slist() {
return new List<int>(ReadLine().Split().Select(int.Parse));
}
static void Main(string[] args) {
var X = Sarray()[0];
var i = 1;
var ans = 0;
while ((i * X) % 360 != 0) {
i++;
}
WriteLine(i);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 250], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79], ["-", 8, 196, 0, 52, 15, 16, 12, 74, 39, 199], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 48], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 8, 196, 0, 52, 15, 16, 12, 74, 51, 22], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 199
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace AC {
class Program {
static void Main(string[] args) {
var X = ReadInt();
var mul = 1;
var K = 360 * mul / X;
while (360 * mul % X != 0)
mul++;
Console.WriteLine(K * mul);
Console.ReadLine();
}
static string Read() { return Console.ReadLine(); }
static int ReadInt() { return int.Parse(Read()); }
static long ReadLong() { return long.Parse(Read()); }
static string[] ReadArrayString() { return Read().Split(' '); }
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;
using System.Runtime.InteropServices;
using System.Text;
namespace AC {
class Program {
static void Main(string[] args) {
var X = ReadInt();
var K = 1;
while (!(K * X >= 360 && K * X % 360 == 0))
K++;
Console.WriteLine(K);
Console.ReadLine();
}
static string Read() { return Console.ReadLine(); }
static int ReadInt() { return int.Parse(Read()); }
static long ReadLong() { return long.Parse(Read()); }
static string[] ReadArrayString() { return Read().Split(' '); }
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, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["+", 0, 195, 8, 196, 0, 52, 15, 241, 0, 111], ["+", 8, 196, 0, 52, 15, 241, 0, 23, 0, 24], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 31, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89], ["-", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["+", 15, 241, 0, 23, 0, 16, 31, 16, 17, 20], ["+", 0, 52, 15, 241, 0, 23, 0, 16, 17, 98], ["+", 0, 16, 12, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 52, 15, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 52, 15, 16, 31, 16, 17, 109], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79], ["+", 0, 23, 0, 16, 12, 16, 31, 16, 17, 109], ["+", 0, 23, 0, 16, 12, 16, 31, 16, 12, 203], ["+", 15, 241, 0, 23, 0, 16, 12, 16, 17, 60], ["-", 8, 196, 0, 52, 8, 1, 0, 223, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 25], ["+", 8, 196, 0, 52, 8, 1, 0, 223, 0, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 238
| 28
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace AGC046 {
using static Ex;
public class Solve {
public static void Main(string[] args) { new AGC_A(); }
}
public class AGC_A {
public AGC_A() {
var x = ReadInt;
var a = 360 % x;
if (a == 0) {
(360 / x).Cw();
return;
}
360.Cw();
}
}
public class AGC_B {
public AGC_B() {}
}
public class AGC_C {
public AGC_C() {}
}
public class AGC_D {
public AGC_D() {}
}
public class AGC_ {
public AGC_() {}
}
public static class Ex {
public static void Cw(this object s) { Console.WriteLine(s); }
public static bool Mins<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
public static bool Maxs<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
public static void Swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
public static void Swap<T>(List<T> list, int i, int j) {
T tmp = list[j];
list[j] = list[i];
list[i] = tmp;
}
public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
public static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }
public static string Read {
get { return Console.ReadLine().Trim(); }
}
public static int ReadInt {
get { return int.Parse(Read); }
}
public static long ReadLong {
get { return long.Parse(Read); }
}
public static double ReadDouble {
get { return double.Parse(Read); }
}
public static string[] ReadArray() { return Read.Split(' '); }
public static int[] ReadIntArray() {
return Read.Split(' ').Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(long.Parse).ToArray();
}
public static string[] ReadArray(long N) {
var v = new string[N];
for (long i = 0; i < N; ++i)
v[i] = Read;
return v;
}
public static int[] ReadIntArray(long N) {
var v = new int[N];
for (long i = 0; i < N; ++i)
v[i] = ReadInt;
return v;
}
public static long[] ReadLongArray(long N) {
var v = new long[N];
for (long i = 0; i < N; ++i)
v[i] = ReadLong;
return v;
}
public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
public static (T, T, T, T) ToTpl4<T>(this T[] v) {
return (v[0], v[1], v[2], v[3]);
}
public static (T, T, T, T, T) ToTpl5<T>(this T[] v) {
return (v[0], v[1], v[2], v[3], v[4]);
}
public static int LowerBound<T>(T[] a, T v) {
return LowerBound(a, v, Comparer<T>.Default);
}
public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp) {
var l = 0;
var r = a.Length - 1;
while (l <= r) {
var mid = l + (r - l) / 2;
var res = cmp.Compare(a[mid], v);
if (res == -1)
l = mid + 1;
else
r = mid - 1;
}
return l;
}
/// <summary>
/// lower_boundは、探索したいkey以上のイテレータを返す
/// upper_boundは、探索したいkeyより大きいイテレータを返す
public static int UpperBound<T>(List<T> a, T v) {
return UpperBound(a, v, Comparer<T>.Default);
}
public static int UpperBound<T>(List<T> a, T v, Comparer<T> cmp) {
var l = 0;
var r = a.Count - 1;
while (l <= r) {
var mid = l + (r - l) / 2;
var res = cmp.Compare(a[mid], v);
if (res <= 0)
l = mid + 1;
else
r = mid - 1;
}
return l;
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace AGC046 {
using static Ex;
public class Solve {
public static void Main(string[] args) { new AGC_A(); }
}
public class AGC_A {
public AGC_A() {
var x = ReadInt;
var b = Lcm(x, 360) / x;
b.Cw();
}
}
public class AGC_B {
public AGC_B() {}
}
public class AGC_C {
public AGC_C() {}
}
public class AGC_D {
public AGC_D() {}
}
public class AGC_ {
public AGC_() {}
}
public static class Ex {
public static void Cw(this object s) { Console.WriteLine(s); }
public static bool Mins<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
public static bool Maxs<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
public static void Swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
public static void Swap<T>(List<T> list, int i, int j) {
T tmp = list[j];
list[j] = list[i];
list[i] = tmp;
}
public static long Lcm(int x, int y) { return x / Gcd(x, y) * y; }
public static long Gcd(long m, long n) {
if (n == 0)
return m;
return Gcd(n, m % n);
}
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }
public static string Read {
get { return Console.ReadLine().Trim(); }
}
public static int ReadInt {
get { return int.Parse(Read); }
}
public static long ReadLong {
get { return long.Parse(Read); }
}
public static double ReadDouble {
get { return double.Parse(Read); }
}
public static string[] ReadArray() { return Read.Split(' '); }
public static int[] ReadIntArray() {
return Read.Split(' ').Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(long.Parse).ToArray();
}
public static string[] ReadArray(long N) {
var v = new string[N];
for (long i = 0; i < N; ++i)
v[i] = Read;
return v;
}
public static int[] ReadIntArray(long N) {
var v = new int[N];
for (long i = 0; i < N; ++i)
v[i] = ReadInt;
return v;
}
public static long[] ReadLongArray(long N) {
var v = new long[N];
for (long i = 0; i < N; ++i)
v[i] = ReadLong;
return v;
}
public static (T, T) ToTpl2<T>(this T[] v) { return (v[0], v[1]); }
public static (T, T, T) ToTpl3<T>(this T[] v) { return (v[0], v[1], v[2]); }
public static (T, T, T, T) ToTpl4<T>(this T[] v) {
return (v[0], v[1], v[2], v[3]);
}
public static (T, T, T, T, T) ToTpl5<T>(this T[] v) {
return (v[0], v[1], v[2], v[3], v[4]);
}
public static int LowerBound<T>(T[] a, T v) {
return LowerBound(a, v, Comparer<T>.Default);
}
public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp) {
var l = 0;
var r = a.Length - 1;
while (l <= r) {
var mid = l + (r - l) / 2;
var res = cmp.Compare(a[mid], v);
if (res == -1)
l = mid + 1;
else
r = mid - 1;
}
return l;
}
/// <summary>
/// lower_boundは、探索したいkey以上のイテレータを返す
/// upper_boundは、探索したいkeyより大きいイテレータを返す
public static int UpperBound<T>(List<T> a, T v) {
return UpperBound(a, v, Comparer<T>.Default);
}
public static int UpperBound<T>(List<T> a, T v, Comparer<T> cmp) {
var l = 0;
var r = a.Count - 1;
while (l <= r) {
var mid = l + (r - l) / 2;
var res = cmp.Compare(a[mid], v);
if (res <= 0)
l = mid + 1;
else
r = mid - 1;
}
return l;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 201, 0, 263, 8, 196, 0, 197, 0, 35], ["-", 8, 201, 0, 263, 8, 196, 0, 57, 0, 121], ["+", 0, 200, 0, 212, 0, 16, 31, 213, 63, 22], ["-", 0, 263, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 263, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 263, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 263, 8, 196, 0, 57, 0, 25], ["-", 0, 263, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 1, 0, 213, 63, 214, 205, 23, 0, 24], ["+", 0, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 212, 0, 16, 31, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 16, 31, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 213, 63, 214, 205, 23, 0, 25], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 0, 263, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 203], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
| 8
| 1,236
| 27
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
using System.Threading;
using static System.Math;
using static System.Array;
using static AtCoder.IO_ShortCut;
using static AtCoder.Tool;
using static AtCoder.ModInt;
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 th = new Thread(Run, 1 << 26);
th.Start();
th.Join();
// Run();
Console.Out.Flush();
}
static void Run() {
int Testcase = 1;
for (var _ = 0; _ < Testcase; _++)
Solve();
}
static void Solve() {
// mod は OK?
long X = Long;
if (360 % X == 0) {
OutL(360 / X);
} else
OutL(360);
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
struct ModInt {
public long value;
// private const int MOD = 1000000007;
private const int MOD = 998244353;
public ModInt(long value) { this.value = value; }
public static implicit operator ModInt(long a) {
var ret = a % MOD;
return new ModInt(ret < 0 ? (ret + MOD) : ret);
}
public static ModInt operator +(ModInt a, ModInt b) => (a.value + b.value);
public static ModInt operator -(ModInt a, ModInt b) => (a.value - b.value);
public static ModInt operator *(ModInt a, ModInt b) => (a.value * b.value);
public static ModInt operator /(ModInt a, ModInt b) => a * Modpow(b, MOD - 2);
public static ModInt operator <<(ModInt a, int n) => (a.value << n);
public static ModInt operator>>(ModInt a, int n) => (a.value >> n);
public static ModInt operator ++(ModInt a) => a.value + 1;
public static ModInt operator --(ModInt a) => a.value - 1;
public static ModInt Modpow(ModInt a, long n) {
var k = a;
ModInt ret = 1;
while (n > 0) {
if ((n & 1) != 0)
ret *= k;
k *= k;
n >>= 1;
}
return ret;
}
private static readonly List<long> Factorials = new List<long>() { 1 };
public static ModInt Fac(long n) {
for (var i = Factorials.Count(); i <= n; i++) {
Factorials.Add((Factorials[i - 1] * i) % MOD);
}
return Factorials[(int)n];
}
public static ModInt nCr(long n, long r) {
return n < r ? 0 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(ModInt a) => (int)a.value;
}
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) {
if (typeof(T).Equals(typeof(ModInt))) {
return (T)(dynamic)(long.Parse(input));
}
return (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 Input<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
d = Conv<W>(q[3]);
e = Conv<X>(q[4]);
}
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 Gcd(long a, long b) {
if (a == 0 || b == 0)
return Max(a, b);
return a % b == 0 ? b : Gcd(b, a % b);
}
static public long LPow(int a, int b) => (long)Pow(a, b);
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public int Sig(long a) => a == 0 ? 0 : (int)(a / Abs(a));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Numerics;
using System.Threading;
using static System.Math;
using static System.Array;
using static AtCoder.IO_ShortCut;
using static AtCoder.Tool;
using static AtCoder.ModInt;
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 th = new Thread(Run, 1 << 26);
th.Start();
th.Join();
// Run();
Console.Out.Flush();
}
static void Run() {
int Testcase = 1;
for (var _ = 0; _ < Testcase; _++)
Solve();
}
static void Solve() {
// mod は OK?
long X = Long;
var G = Gcd(360, X);
if (360 % X == 0) {
OutL(360 / X);
} else {
OutL(360 / G);
}
}
public struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
struct ModInt {
public long value;
// private const int MOD = 1000000007;
private const int MOD = 998244353;
public ModInt(long value) { this.value = value; }
public static implicit operator ModInt(long a) {
var ret = a % MOD;
return new ModInt(ret < 0 ? (ret + MOD) : ret);
}
public static ModInt operator +(ModInt a, ModInt b) => (a.value + b.value);
public static ModInt operator -(ModInt a, ModInt b) => (a.value - b.value);
public static ModInt operator *(ModInt a, ModInt b) => (a.value * b.value);
public static ModInt operator /(ModInt a, ModInt b) => a * Modpow(b, MOD - 2);
public static ModInt operator <<(ModInt a, int n) => (a.value << n);
public static ModInt operator>>(ModInt a, int n) => (a.value >> n);
public static ModInt operator ++(ModInt a) => a.value + 1;
public static ModInt operator --(ModInt a) => a.value - 1;
public static ModInt Modpow(ModInt a, long n) {
var k = a;
ModInt ret = 1;
while (n > 0) {
if ((n & 1) != 0)
ret *= k;
k *= k;
n >>= 1;
}
return ret;
}
private static readonly List<long> Factorials = new List<long>() { 1 };
public static ModInt Fac(long n) {
for (var i = Factorials.Count(); i <= n; i++) {
Factorials.Add((Factorials[i - 1] * i) % MOD);
}
return Factorials[(int)n];
}
public static ModInt nCr(long n, long r) {
return n < r ? 0 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(ModInt a) => (int)a.value;
}
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) {
if (typeof(T).Equals(typeof(ModInt))) {
return (T)(dynamic)(long.Parse(input));
}
return (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 Input<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var q = _ReadSplit;
a = Conv<T>(q[0]);
b = Conv<U>(q[1]);
c = Conv<V>(q[2]);
d = Conv<W>(q[3]);
e = Conv<X>(q[4]);
}
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 Gcd(long a, long b) {
if (a == 0 || b == 0)
return Max(a, b);
return a % b == 0 ? b : Gcd(b, a % b);
}
static public long LPow(int a, int b) => (long)Pow(a, b);
static public bool Bit(long x, int dig) => ((1L << dig) & x) != 0;
static public int Sig(long a) => a == 0 ? 0 : (int)(a / Abs(a));
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 1,763
| 14
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
int c = int.Parse(input[2]);
int d = int.Parse(input[3]);
long mod = 998244353;
long[][] dp = new long [c + 1][];
for (int i = 0; i <= c; i++)
dp[i] = new long[d + 1];
if (a != c || b != d)
dp[a][b] = 1;
for (int col = b; col <= d; col++) {
for (int row = a; row <= c; row++) {
if (col == b && row == a)
continue;
long dpTmp = (dp[row - 1][col] * (long)col) % mod;
dpTmp = (dpTmp + (dp[row][col - 1] * (long)row) % mod) % mod;
dpTmp = (dpTmp + mod -
((dp[row - 1][col - 1] * ((long)row - 1) * ((long)col - 1)) %
mod)) %
mod;
dp[row][col] = dpTmp;
}
}
Console.WriteLine(dp[c][d]);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
int c = int.Parse(input[2]);
int d = int.Parse(input[3]);
long mod = 998244353;
long[][] dp = new long [c + 1][];
for (int i = 0; i <= c; i++)
dp[i] = new long[d + 1];
dp[a][b] = 1;
for (int col = b; col <= d; col++) {
for (int row = a; row <= c; row++) {
if (col == b && row == a)
continue;
long dpTmp = (dp[row - 1][col] * (long)col) % mod;
dpTmp = (dpTmp + (dp[row][col - 1] * (long)row) % mod) % mod;
dpTmp = (dpTmp + mod -
((dp[row - 1][col - 1] * ((long)row - 1) * ((long)col - 1)) %
mod)) %
mod;
dp[row][col] = dpTmp;
}
}
Console.WriteLine(dp[c][d]);
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 326
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atc_0034 {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
int X = int.Parse(str.Split(' ')[0]);
int Y = int.Parse(str.Split(' ')[1]);
for (int i = 0; i <= X; i++) {
for (int j = X - i; 0 <= j; j--) {
if (Y == (2 * i + 4 * j)) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atc_0034 {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
int X = int.Parse(str.Split(' ')[0]);
int Y = int.Parse(str.Split(' ')[1]);
for (int i = 0; i <= X; i++) {
if (Y == (2 * i + 4 * (X - i))) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 10, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 203], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 68], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 15, 16, 12, 23, 0, 16, 12, 16, 12, 22], ["+", 12, 23, 0, 16, 12, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 165
| 24
|
using System;
using System.Linq;
namespace atcoder.abc170.b {
class Program {
static void Main(string[] args) {
int[] inputArray = getIntParams();
int X = inputArray[0];
int Y = inputArray[1];
for (int i = 0; i <= X; i++) {
for (int j = X; j >= 0; j--) {
if (4 * i + 2 * j == Y) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
//↓↓↓ shared function ↓↓↓
static int getIntParam() { return int.Parse(Console.ReadLine()); }
static int[] getIntParams() {
return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
}
static long getLongParam() { return long.Parse(Console.ReadLine()); }
static long[] getLongParams() {
return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
}
static string getStringParam() { return Console.ReadLine(); }
static string[] getStringParams() { return Console.ReadLine().Split(' '); }
}
}
|
using System;
using System.Linq;
namespace atcoder.abc170.b {
class Program {
static void Main(string[] args) {
int[] inputArray = getIntParams();
int X = inputArray[0];
int Y = inputArray[1];
for (int i = 0; i <= X; i++) {
int j = X - i;
if (4 * i + 2 * j == Y) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
//↓↓↓ shared function ↓↓↓
static int getIntParam() { return int.Parse(Console.ReadLine()); }
static int[] getIntParams() {
return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
}
static long getLongParam() { return long.Parse(Console.ReadLine()); }
static long[] getLongParams() {
return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
}
static string getStringParam() { return Console.ReadLine(); }
static string[] getStringParams() { return Console.ReadLine().Split(' '); }
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 20], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 68], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 276
| 13
|
using System;
namespace ConsoleApp31 {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
string[] array = line.Split(' ');
int x = int.Parse(array[0]);
int y = int.Parse(array[1]);
if (y % 2 == 0) {
if (x <= y / 2 && x >= y / 4) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace ConsoleApp31 {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
string[] array = line.Split(' ');
int x = int.Parse(array[0]);
int y = int.Parse(array[1]);
if (y % 2 == 0) {
if (x * 2 <= y && x * 4 >= y) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
} else {
Console.WriteLine("No");
}
}
}
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 12, 203]]
| 8
| 130
| 8
|
using System;
using System.Linq;
namespace _170_b {
internal class CraneAndTurtle {
private static void Main(string[] args) {
var xy = Console.ReadLine()?.Split(" ").Select(int.Parse).ToArray();
if (xy == null)
return;
var x = xy[0];
var y = xy[1];
if (y % 2 != 0) {
Console.WriteLine("No");
return;
}
if (x * 4 < y) {
Console.WriteLine("No");
return;
}
Console.WriteLine("Yes");
}
}
}
|
using System;
using System.Linq;
namespace _170_b {
internal class CraneAndTurtle {
private static void Main(string[] args) {
var xy = Console.ReadLine()?.Split(" ").Select(int.Parse).ToArray();
if (xy == null)
return;
var x = xy[0];
var y = xy[1];
// 奇数
if (y % 2 != 0) {
Console.WriteLine("No");
return;
}
// 足が足りない
if (x * 4 < y) {
Console.WriteLine("No");
return;
}
// 足が余る
if (x * 2 > y) {
Console.WriteLine("No");
return;
}
Console.WriteLine("Yes");
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
| 8
| 132
| 21
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Util {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
int[] XY = ria();
int X = XY[0];
int Y = XY[1];
// string[][] animalArrayArray = Combination.Enumerate(new string[]{"亀",
// "鶴"}, X, withRepetition: true).ToArray();
// foreach(string[] animalArray in animalArrayArray) {
// int legCnt = 0;
// foreach(string animal in animalArray) {
// switch(animal) {
// case "鶴":
// legCnt += 2;
// break;
// case "亀":
// legCnt += 4;
// break;
// }
// if(legCnt == Y) {
// Console.WriteLine("Yes");
// Console.ReadLine();
// return;
// }
// }a
// }
// Console.WriteLine("No");
string ans = "No";
if (Y / 2 == Y / 2.0) {
if (2 * X - Y / 2 >= 0)
ans = "Yes";
}
Console.WriteLine(ans);
Console.ReadLine();
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
static int[] generateNums(int num, int N) {
return Enumerable.Repeat(num, N).ToArray();
}
static int[] generateSuretsu(int N) {
return Enumerable.Range(0, N).ToArray();
}
}
public static class Combination {
//使い方:int[][] Is = Combination.Enumerate(nums, k,
//withRepetition:false).ToArray();
public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k,
bool withRepetition) {
if (k == 1) {
foreach (var item in items)
yield return new T[] { item };
yield break;
}
foreach (var item in items) {
var leftside = new T[] { item };
// item よりも前のものを除く (順列と組み合わせの違い)
// 重複を許さないので、unusedから item そのものも取り除く
var unused = withRepetition
? items
: items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();
foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
yield return leftside.Concat(rightside).ToArray();
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Util {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
int[] XY = ria();
int X = XY[0];
int Y = XY[1];
string ans = "No";
for (int i = 0; i <= X; i++) {
int crane = X - i;
if (2 * i + 4 * crane == Y)
ans = "Yes";
}
// Console.WriteLine("No");
// string ans = "No";
// if(Y / 2 == Y / 2.0) {
// if(2 * X - Y / 2 >= 0) ans = "Yes";
// }
Console.WriteLine(ans);
Console.ReadLine();
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
static int[] generateNums(int num, int N) {
return Enumerable.Repeat(num, N).ToArray();
}
static int[] generateSuretsu(int N) {
return Enumerable.Range(0, N).ToArray();
}
}
public static class Combination {
//使い方:int[][] Is = Combination.Enumerate(nums, k,
//withRepetition:false).ToArray();
public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k,
bool withRepetition) {
if (k == 1) {
foreach (var item in items)
yield return new T[] { item };
yield break;
}
foreach (var item in items) {
var leftside = new T[] { item };
// item よりも前のものを除く (順列と組み合わせの違い)
// 重複を許さないので、unusedから item そのものも取り除く
var unused = withRepetition
? items
: items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();
foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
yield return leftside.Concat(rightside).ToArray();
}
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 85], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 85], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 250], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 203], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 578
| 39
|
using System;
using System.Collections.Generic;
class Program {
private const int CRANE_LEGS = 2;
public static void Main(string[] args) {
int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
Program pg = new Program();
Console.WriteLine(pg.Exe(input));
}
public string Exe(int[] input) {
string answer = "No";
int animals = input[0];
int legs = input[1];
if (legs % 2 == 1)
return answer;
int crane_cnt = animals;
int num_legs = crane_cnt * CRANE_LEGS;
if ((legs - num_legs) / 2 > animals)
return answer;
else
answer = "Yes";
return answer;
}
}
|
using System;
using System.Collections.Generic;
class Program {
private const int CRANE_LEGS = 2;
public static void Main(string[] args) {
int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
Program pg = new Program();
Console.WriteLine(pg.Exe(input));
}
public string Exe(int[] input) {
string answer = "No";
int animals = input[0];
int legs = input[1];
if (legs % 2 == 1)
return answer;
int crane_cnt = animals;
int num_legs = crane_cnt * CRANE_LEGS;
if ((legs - num_legs) / 2 > animals)
return answer;
if ((legs - num_legs) < 0)
return answer;
else
answer = "Yes";
return answer;
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 24], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35]]
| 8
| 162
| 13
|
using System;
namespace ABC171B {
class Program {
static void Main(string[] args) {
int n, k;
var aa = Console.ReadLine().Split(" ");
n = int.Parse(aa[0]);
k = int.Parse(aa[1]);
int x = 0;
int[] a = new int[n];
var ac = Console.ReadLine().Split(" ");
for (int i = 0; i < n; i++)
a[i] = int.Parse(ac[i]);
Array.Sort(a, (e, b) => e - b);
for (int i = 0; i < k; i++) {
Console.WriteLine(a[i]);
x += a[i];
}
Console.WriteLine(x);
}
}
}
|
using System;
namespace ABC171B {
class Program {
static void Main(string[] args) {
int n, k;
var aa = Console.ReadLine().Split(" ");
n = int.Parse(aa[0]);
k = int.Parse(aa[1]);
int x = 0;
int[] a = new int[n];
var ac = Console.ReadLine().Split(" ");
for (int i = 0; i < n; i++)
a[i] = int.Parse(ac[i]);
Array.Sort(a, (e, b) => e - b);
for (int i = 0; i < k; i++) {
// Console.WriteLine(a[i]);
x += a[i];
}
Console.WriteLine(x);
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 185
| 10
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace C {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var N = long.Parse(Console.ReadLine());
var answer = "";
while (N > 0) {
var div = N / 26L;
var mod = N % 26L;
answer += GetCharString(mod);
N = div;
}
Console.WriteLine(string.Join("", answer.Reverse()));
}
public static string GetCharString(long num) {
var ret = "";
switch (num) {
case 1:
ret = "a";
break;
case 2:
ret = "b";
break;
case 3:
ret = "c";
break;
case 4:
ret = "d";
break;
case 5:
ret = "e";
break;
case 6:
ret = "f";
break;
case 7:
ret = "g";
break;
case 8:
ret = "h";
break;
case 9:
ret = "i";
break;
case 10:
ret = "j";
break;
case 11:
ret = "k";
break;
case 12:
ret = "l";
break;
case 13:
ret = "m";
break;
case 14:
ret = "n";
break;
case 15:
ret = "o";
break;
case 16:
ret = "p";
break;
case 17:
ret = "q";
break;
case 18:
ret = "r";
break;
case 19:
ret = "s";
break;
case 20:
ret = "t";
break;
case 21:
ret = "u";
break;
case 22:
ret = "v";
break;
case 23:
ret = "w";
break;
case 24:
ret = "x";
break;
case 26:
ret = "y";
break;
case 0:
ret = "z";
break;
}
return ret;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace C {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var N = long.Parse(Console.ReadLine());
var answer = "";
while (N > 0) {
var div = (N - 1) / 26L;
var mod = (N - 1) % 26L;
answer += GetCharString(mod);
N = div;
}
Console.WriteLine(string.Join("", answer.Reverse()));
}
public static string GetCharString(long num) {
var ret = "";
switch (num) {
case 0:
ret = "a";
break;
case 1:
ret = "b";
break;
case 2:
ret = "c";
break;
case 3:
ret = "d";
break;
case 4:
ret = "e";
break;
case 5:
ret = "f";
break;
case 6:
ret = "g";
break;
case 7:
ret = "h";
break;
case 8:
ret = "i";
break;
case 9:
ret = "j";
break;
case 10:
ret = "k";
break;
case 11:
ret = "l";
break;
case 12:
ret = "m";
break;
case 13:
ret = "n";
break;
case 14:
ret = "o";
break;
case 15:
ret = "p";
break;
case 16:
ret = "q";
break;
case 17:
ret = "r";
break;
case 18:
ret = "s";
break;
case 19:
ret = "t";
break;
case 20:
ret = "u";
break;
case 21:
ret = "v";
break;
case 22:
ret = "w";
break;
case 23:
ret = "x";
break;
case 24:
ret = "y";
break;
case 25:
ret = "z";
break;
}
return ret;
}
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["-", 0, 99, 8, 254, 0, 239, 0, 264, 0, 203], ["+", 0, 99, 8, 254, 0, 239, 0, 264, 0, 203]]
| 8
| 473
| 60
|
using System;
using System.Linq;
class program {
static void Main() {
long n = long.Parse(Console.ReadLine());
string a = "";
while (n > 0) {
a += (char)(n % 26 + 96);
n = n / 26;
}
string ans = string.Concat(a.Reverse());
Console.Write(ans);
}
}
|
using System;
using System.Linq;
class program {
static void Main() {
long n = long.Parse(Console.ReadLine());
string a = "";
while (n > 0) {
a += (char)((n - 1) % 26 + 97);
n = (n - 1) / 26;
}
string ans = string.Concat(a.Reverse());
Console.Write(ans);
}
}
|
[["+", 51, 23, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 51, 23, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 0, 11, 12, 74, 51, 23, 0, 16, 12, 203], ["+", 0, 11, 12, 74, 51, 23, 0, 16, 12, 203], ["+", 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
| 87
| 10
|
using System;
using System.Collections.Generic;
public class Program {
public static void Main() {
long number = long.Parse(Console.ReadLine());
List<int> result = new List<int>();
int baseNumber = 26;
while (number != 0) {
number--;
result.Add((int)(number % baseNumber));
number = number / baseNumber;
}
foreach (int item in result) {
Console.Write((char)(item + (int)'a'));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Program {
public static void Main() {
long number = long.Parse(Console.ReadLine());
List<int> result = new List<int>();
int baseNumber = 26;
while (number != 0) {
number--;
result.Add((int)(number % baseNumber));
number = number / baseNumber;
}
foreach (int item in result.AsEnumerable().Reverse()) {
Console.Write((char)(item + (int)'a'));
}
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 210, 12, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 25]]
| 8
| 115
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
class Progaram {
static List<char> resl = new List<char>();
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
Saiki(N);
Console.WriteLine(new String(resl.ToArray()));
}
static void Saiki(long N) {
var w = N / 26;
var z = N % 26;
var ca = (int)'a';
ca += (int)((z == 0) ? 25 : z - 1);
resl.Insert(0, (char)ca);
if (w == 0)
return;
Saiki(w);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
class Progaram {
static List<char> resl = new List<char>();
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
Saiki(N);
Console.WriteLine(new String(resl.ToArray()));
}
static void Saiki(long N) {
var w = N / 26;
var z = N % 26;
var ca = (int)'a';
if (z == 0) {
w--;
z = 26;
}
ca += (int)z - 1;
resl.Insert(0, (char)ca);
if (w == 0)
return;
Saiki(w);
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 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, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 12, 74, 51, 23, 0, 41, 15, 23, 0, 24], ["-", 0, 11, 12, 74, 51, 23, 0, 41, 0, 101], ["-", 0, 11, 12, 74, 51, 23, 0, 41, 64, 203], ["-", 0, 11, 12, 74, 51, 23, 0, 41, 0, 102], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 39, 199], ["+", 0, 1, 0, 11, 12, 16, 31, 74, 0, 25], ["-", 0, 1, 0, 11, 12, 74, 51, 23, 0, 25]]
| 8
| 156
| 30
|
using System;
namespace ABC171C {
class Program {
static void Main(string[] args) {
ulong n = ulong.Parse(Console.ReadLine());
string s = null;
int f = 0;
double ss = Math.Pow(26, 6) + Math.Pow(26, 5) + Math.Pow(26, 4) +
Math.Pow(26, 3) + Math.Pow(26, 2) + Math.Pow(26, 1);
if (0 < n && n <= Math.Pow(26, 1))
f = 1;
if (Math.Pow(26, 1) < n)
f = 2;
if (Math.Pow(26, 2) + Math.Pow(26, 1) < n)
f = 3;
if (Math.Pow(26, 3) + Math.Pow(26, 2) + Math.Pow(26, 1) < n)
f = 4;
if (Math.Pow(26, 4) + Math.Pow(26, 3) + Math.Pow(26, 2) + Math.Pow(26, 1) <
n)
f = 5;
if (Math.Pow(26, 5) + Math.Pow(26, 4) + Math.Pow(26, 3) + Math.Pow(26, 2) +
Math.Pow(26, 1) <
n)
f = 6;
if (Math.Pow(26, 6) + Math.Pow(26, 5) + Math.Pow(26, 4) + Math.Pow(26, 3) +
Math.Pow(26, 2) + Math.Pow(26, 1) <
n)
f = 7;
if (Math.Pow(26, 7) + ss < n)
f = 8;
if (Math.Pow(26, 8) + Math.Pow(26, 7) + ss < n)
f = 9;
if (Math.Pow(26, 9) + Math.Pow(26, 8) + Math.Pow(26, 7) + ss < n)
f = 10;
if (Math.Pow(26, 10) + Math.Pow(26, 9) + Math.Pow(26, 8) + Math.Pow(26, 7) +
ss <
n)
f = 11;
ulong[] a = new ulong[f + 1];
for (int i = 0; i < f; i++) {
n = n - (ulong)Math.Pow(26, i);
}
// Console.WriteLine(n);
for (int i = 1; i <= f; i++) {
a[f - i] = n % (ulong)Math.Pow(26, i);
n /= (ulong)Math.Pow(26, i);
// Console.Write(a[i]+" ");
}
for (int i = 0; i < f; i++) {
if (a[i] == 0) {
s += "a";
}
if (a[i] == 1) {
s += "b";
}
if (a[i] == 2) {
s += "c";
}
if (a[i] == 3) {
s += "d";
}
if (a[i] == 4) {
s += "e";
}
if (a[i] == 5) {
s += "f";
}
if (a[i] == 6) {
s += "g";
}
if (a[i] == 7) {
s += "h";
}
if (a[i] == 8) {
s += "i";
}
if (a[i] == 9) {
s += "j";
}
if (a[i] == 10) {
s += "k";
}
if (a[i] == 11) {
s += "l";
}
if (a[i] == 12) {
s += "m";
}
if (a[i] == 13) {
s += "n";
}
if (a[i] == 14) {
s += "o";
}
if (a[i] == 15) {
s += "p";
}
if (a[i] == 16) {
s += "q";
}
if (a[i] == 17) {
s += "r";
}
if (a[i] == 18) {
s += "s";
}
if (a[i] == 19) {
s += "t";
}
if (a[i] == 20) {
s += "u";
}
if (a[i] == 21) {
s += "v";
}
if (a[i] == 22) {
s += "w";
}
if (a[i] == 23) {
s += "x";
}
if (a[i] == 24) {
s += "y";
}
if (a[i] == 25) {
s += "z";
}
}
Console.WriteLine(s);
}
}
}
|
using System;
namespace ABC171C {
class Program {
static void Main(string[] args) {
ulong n = ulong.Parse(Console.ReadLine());
string s = null;
int f = 0;
double ss = Math.Pow(26, 6) + Math.Pow(26, 5) + Math.Pow(26, 4) +
Math.Pow(26, 3) + Math.Pow(26, 2) + Math.Pow(26, 1);
if (0 < n && n <= Math.Pow(26, 1))
f = 1;
if (Math.Pow(26, 1) < n)
f = 2;
if (Math.Pow(26, 2) + Math.Pow(26, 1) < n)
f = 3;
if (Math.Pow(26, 3) + Math.Pow(26, 2) + Math.Pow(26, 1) < n)
f = 4;
if (Math.Pow(26, 4) + Math.Pow(26, 3) + Math.Pow(26, 2) + Math.Pow(26, 1) <
n)
f = 5;
if (Math.Pow(26, 5) + Math.Pow(26, 4) + Math.Pow(26, 3) + Math.Pow(26, 2) +
Math.Pow(26, 1) <
n)
f = 6;
if (Math.Pow(26, 6) + Math.Pow(26, 5) + Math.Pow(26, 4) + Math.Pow(26, 3) +
Math.Pow(26, 2) + Math.Pow(26, 1) <
n)
f = 7;
if (Math.Pow(26, 7) + ss < n)
f = 8;
if (Math.Pow(26, 8) + Math.Pow(26, 7) + ss < n)
f = 9;
if (Math.Pow(26, 9) + Math.Pow(26, 8) + Math.Pow(26, 7) + ss < n)
f = 10;
if (Math.Pow(26, 10) + Math.Pow(26, 9) + Math.Pow(26, 8) + Math.Pow(26, 7) +
ss <
n)
f = 11;
ulong[] a = new ulong[f + 1];
for (int i = 0; i < f; i++) {
n = n - (ulong)Math.Pow(26, i);
}
// Console.Write(f+" ");
// Console.WriteLine(n);
for (int i = 1; i <= f; i++) {
a[f - i] = n % 26;
n /= 26;
}
// Console.WriteLine(n);
for (int i = 0; i < f; i++) {
// Console.Write(a[i]+" ");
if (a[i] == 0) {
s += "a";
}
if (a[i] == 1) {
s += "b";
}
if (a[i] == 2) {
s += "c";
}
if (a[i] == 3) {
s += "d";
}
if (a[i] == 4) {
s += "e";
}
if (a[i] == 5) {
s += "f";
}
if (a[i] == 6) {
s += "g";
}
if (a[i] == 7) {
s += "h";
}
if (a[i] == 8) {
s += "i";
}
if (a[i] == 9) {
s += "j";
}
if (a[i] == 10) {
s += "k";
}
if (a[i] == 11) {
s += "l";
}
if (a[i] == 12) {
s += "m";
}
if (a[i] == 13) {
s += "n";
}
if (a[i] == 14) {
s += "o";
}
if (a[i] == 15) {
s += "p";
}
if (a[i] == 16) {
s += "q";
}
if (a[i] == 17) {
s += "r";
}
if (a[i] == 18) {
s += "s";
}
if (a[i] == 19) {
s += "t";
}
if (a[i] == 20) {
s += "u";
}
if (a[i] == 21) {
s += "v";
}
if (a[i] == 22) {
s += "w";
}
if (a[i] == 23) {
s += "x";
}
if (a[i] == 24) {
s += "y";
}
if (a[i] == 25) {
s += "z";
}
}
Console.WriteLine(s);
}
}
}
|
[["-", 0, 1, 0, 11, 12, 16, 12, 74, 0, 24], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 39, 199], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25], ["-", 12, 16, 12, 74, 51, 213, 63, 214, 205, 22], ["-", 12, 16, 12, 74, 51, 213, 63, 214, 0, 131], ["-", 12, 16, 12, 74, 51, 213, 63, 214, 141, 22], ["-", 12, 16, 12, 74, 51, 213, 3, 4, 0, 24], ["-", 12, 16, 12, 74, 51, 213, 3, 4, 0, 21], ["-", 12, 74, 51, 213, 3, 4, 0, 28, 0, 22], ["-", 12, 16, 12, 74, 51, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 0, 24], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25], ["-", 0, 11, 12, 74, 51, 213, 63, 214, 205, 22], ["-", 0, 11, 12, 74, 51, 213, 63, 214, 0, 131], ["-", 0, 11, 12, 74, 51, 213, 63, 214, 141, 22], ["-", 0, 11, 12, 74, 51, 213, 3, 4, 0, 24], ["-", 0, 11, 12, 74, 51, 213, 3, 4, 0, 21], ["-", 0, 11, 12, 74, 51, 213, 3, 4, 0, 25]]
| 8
| 1,054
| 20
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadLong();
var ans = "";
while (N > 0) {
var rem = N % 26;
ans += (char)('a' + rem - 1);
N /= 26;
}
ans = new string(ans.Reverse().ToArray());
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
static void Solve() {
var N = sc.ReadLong() - 1;
var res = $"{(char)('a' + N % 26)}";
N /= 26;
while (N != 0) {
N--;
res += (char)('a' + N % 26);
N /= 26;
}
Console.WriteLine(new string(res.Reverse().ToArray()));
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["+", 0, 198, 0, 200, 0, 212, 0, 283, 0, 295], ["+", 0, 200, 0, 212, 0, 283, 0, 284, 0, 45], ["+", 0, 212, 0, 283, 0, 284, 0, 74, 0, 24], ["+", 0, 212, 0, 283, 0, 284, 0, 74, 39, 199], ["+", 0, 212, 0, 283, 0, 284, 0, 74, 0, 25], ["+", 0, 283, 0, 284, 0, 74, 51, 23, 0, 24], ["+", 0, 74, 51, 23, 0, 16, 31, 252, 0, 104], ["+", 0, 74, 51, 23, 0, 16, 31, 252, 0, 253], ["+", 0, 284, 0, 74, 51, 23, 0, 16, 17, 72], ["+", 0, 74, 51, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 74, 51, 23, 0, 16, 12, 16, 17, 109], ["+", 0, 74, 51, 23, 0, 16, 12, 16, 12, 203], ["+", 0, 283, 0, 284, 0, 74, 51, 23, 0, 25], ["+", 0, 200, 0, 212, 0, 283, 0, 284, 0, 46], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 68], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 12, 74, 51, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 11, 12, 74, 51, 23, 0, 16, 17, 33], ["-", 0, 11, 12, 74, 51, 23, 0, 16, 12, 203], ["+", 12, 74, 51, 23, 0, 16, 12, 16, 31, 22], ["+", 12, 74, 51, 23, 0, 16, 12, 16, 17, 109], ["+", 12, 74, 51, 23, 0, 16, 12, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,127
| 54
|
using System;
using System.Text;
namespace AtCoder.Abcdef {
public class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
long n = long.Parse(Console.ReadLine());
string str = "zabcdefghijklmnopqrstuvwxy";
var sb = new StringBuilder();
while (n > 0) {
var remainder = (int)(n % 26);
sb.Insert(0, str[remainder]);
n = n / 26;
}
Console.WriteLine(sb.ToString());
Console.Out.Flush();
}
}
}
|
using System;
using System.Text;
namespace AtCoder.Abcdef {
public class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// Input integer
long n = long.Parse(Console.ReadLine());
var sb = new StringBuilder();
while (n > 0) {
n--;
var remainder = (int)(n % 26);
sb.Insert(0, (char)('a' + remainder));
n = n / 26;
}
Console.WriteLine(sb.ToString());
Console.Out.Flush();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 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], ["+", 0, 74, 51, 23, 0, 16, 31, 252, 0, 104], ["+", 0, 74, 51, 23, 0, 16, 31, 252, 0, 253], ["+", 0, 28, 0, 74, 51, 23, 0, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 74, 51, 23, 0, 25]]
| 8
| 146
| 22
|
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) {
var N = GetLongNum();
var str = "zabcdefghijklmnopqrstuvwxyz";
var a = N / 26;
var b = N % 26;
var ans = string.Empty;
while (true) {
ans = str[(int)b].ToString() + ans;
if (1 <= a && a <= 26) {
ans = str[(int)a].ToString() + ans;
break;
} else if (a == 0) {
break;
}
b = a % 26;
a = a / 26;
}
Console.WriteLine(ans);
}
private static long[] GetLongNumArray() {
var input = Console.ReadLine().Split(' ');
return input.Select(x => long.Parse(x)).ToArray();
}
private static long GetLongNum() { return long.Parse(Console.ReadLine()); }
private static string[] GetStringArray() {
return Console.ReadLine().Split(' ');
}
private static string GetString() { return Console.ReadLine(); }
}
}
|
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) {
var N = GetLongNum();
var str = "zabcdefghijklmnopqrstuvwxyz";
var a = N / 26;
var b = N % 26;
var ans = string.Empty;
while (true) {
ans = str[(int)b].ToString() + ans;
if (b == 0) {
a = a - 1;
}
if (1 <= a && a <= 26) {
ans = str[(int)a].ToString() + ans;
break;
} else if (a == 0) {
break;
}
b = a % 26;
a = a / 26;
}
Console.WriteLine(ans);
}
private static long[] GetLongNumArray() {
var input = Console.ReadLine().Split(' ');
return input.Select(x => long.Parse(x)).ToArray();
}
private static long GetLongNum() { return long.Parse(Console.ReadLine()); }
private static string[] GetStringArray() {
return Console.ReadLine().Split(' ');
}
private static string GetString() { return Console.ReadLine(); }
}
}
|
[["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24]]
| 8
| 267
| 14
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class GFG {
public static void Main() {
var ii = Console.ReadLine();
long n = long.Parse(ii);
Dictionary<long, char> dic = new Dictionary<long, char>();
char a = 'a';
for (int i = 1; i <= 26; i++) {
dic[i] = a;
a++;
}
StringBuilder ans = new StringBuilder();
while (n > 0) {
if (n % 26 != 0) {
ans.Append(dic[(n % 26)]);
}
n = n / 26;
}
char[] arr = ans.ToString().ToCharArray();
Array.Reverse(arr);
Console.Write(new string(arr));
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class GFG {
public static void Main() {
var ii = Console.ReadLine();
long n = long.Parse(ii);
Dictionary<long, char> dic = new Dictionary<long, char>();
char a = 'a';
for (int i = 0; i <= 25; i++) {
dic[i] = a;
a++;
}
StringBuilder ans = new StringBuilder();
while (n > 0) {
n = n - 1;
ans.Append(dic[n % 26]);
n = n / 26;
}
char[] arr = ans.ToString().ToCharArray();
Array.Reverse(arr);
Console.Write(new string(arr));
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 0, 204, 206, 207, 0, 28, 0, 23, 0, 24], ["-", 0, 204, 206, 207, 0, 28, 0, 23, 0, 25], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 187
| 20
|
using System;
using System.Collections.Generic;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// long mx = 1000000000000001L;
var c = new char[] { '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' };
var n = long.Parse(Console.ReadLine());
var ca = new List<char>();
for (;;) {
if (n == 0)
break;
var md = n % 26;
n = n / 26;
ca.Add(c[md - 1]);
}
ca.Reverse();
string result = new string(ca.ToArray());
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// long mx = 1000000000000001L;
var c = new char[] { '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' };
// var c = new char[] { '0','1','2','3','4','5','6','7','8','9' };
var n = long.Parse(Console.ReadLine());
var ca = new List<char>();
for (;;) {
if (n == 0)
break;
var md = n % 26L;
if (md > 0) {
ca.Add(c[md - 1]);
} else {
ca.Add('z');
n--;
}
n /= 26L;
}
ca.Reverse();
string result = new string(ca.ToArray());
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["+", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 68], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 274
| 35
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace ABC171 {
class C {
static void Main(string[] args) {
// var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
// var p = Console.ReadLine().Split().Select(long.Parse).OrderBy(x =>
// x).ToArray();
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
// var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
long N = long.Parse(Console.ReadLine());
char[] C = new char[26];
C[0] = 'z';
for (int i = 0; i < 25; i++) {
C[i + 1] = (char)('a' + i);
}
// Console.WriteLine(string.Join(" ", C));
string ans = "";
// ans += C[N % 26];
// long tempN = N / 26;
long tempN = N;
while (tempN > 0) {
ans += C[tempN % 26];
if (tempN == 26)
break;
tempN = tempN / 26 - 1;
}
Console.WriteLine(string.Concat(ans.Reverse()));
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace ABC171 {
class C {
static void Main(string[] args) {
// var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
// var p = Console.ReadLine().Split().Select(long.Parse).OrderBy(x =>
// x).ToArray();
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
// var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
long N = long.Parse(Console.ReadLine());
char[] C = new char[26];
C[0] = 'z';
for (int i = 0; i < 25; i++) {
C[i + 1] = (char)('a' + i);
}
// Console.WriteLine(string.Join(" ", C));
string ans = "";
// ans += C[N % 26];
// long tempN = N / 26;
long tempN = N;
while (tempN > 0) {
ans += C[tempN % 26];
if (tempN % 26 == 0)
tempN = tempN / 26 - 1;
else
tempN /= 26;
}
Console.WriteLine(string.Concat(ans.Reverse()));
}
}
}
|
[["-", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["-", 0, 52, 8, 196, 0, 57, 64, 93, 0, 35], ["+", 0, 52, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 90], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 12, 203]]
| 8
| 176
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC {
class ABC170 {
static ulong N;
static char[] answers;
static List<char> result;
static void Main(String[] args) {
init();
// 26進数
// 再帰 base: i < 26
proc(N);
result.Reverse();
Console.WriteLine(string.Join("", result.ToArray()));
Console.ReadLine();
}
static void proc(ulong n) {
if (n < 26) {
result.Add(answers[n - 1]);
return;
}
ulong quotient = n / 26;
ulong remainder = n % 26;
result.Add(answers[remainder - 1]);
proc(quotient);
}
static void init() {
N = ulong.Parse(Console.ReadLine());
string alphabet = "abcdefghijklmnopqrstuvwxyz";
answers = alphabet.ToCharArray();
result = new List<char>();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC {
class ABC170 {
static ulong N;
static char[] answers;
static List<char> result;
static void Main(String[] args) {
init();
// 26進数
// 再帰 base: i < 26
proc(N);
result.Reverse();
Console.WriteLine(string.Join("", result.ToArray()));
Console.ReadLine();
}
static void proc(ulong n) {
if (n == 0) {
return;
}
if (n < 26) {
result.Add(answers[n - 1]);
return;
}
ulong quotient = n / 26;
ulong remainder = n % 26;
if (remainder == 0) {
result.Add(answers[25]);
quotient--;
} else {
result.Add(answers[remainder - 1]);
}
proc(quotient);
}
static void init() {
N = ulong.Parse(Console.ReadLine());
string alphabet = "abcdefghijklmnopqrstuvwxyz";
answers = alphabet.ToCharArray();
result = new List<char>();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 195, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 212
| 34
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class MainClass {
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput(), Console.Out.Encoding);
sw.AutoFlush = false;
Console.SetOut(sw);
if (args.Length > 0 && args[0] == "debug") {
var inputs = new[] { @"
2
",
@"
27
",
@"
123456789
",
@"
",
@"
" };
foreach (var str in inputs) {
var text = str.TrimStart();
if (text.Length == 0)
continue;
var reader = new System.IO.StringReader(text);
Console.SetIn(reader);
Main2(args);
Console.WriteLine("----------------------------------");
}
} else
Main2(args);
Console.Out.Flush();
}
private static void Main2(string[] args) {
checked {
// var MAX = 1000000000000001L;
var N = long.Parse(Console.ReadLine());
var res = "";
while (N > 0) {
var s = N % 26;
res = (char)('a' + s - 1) + res;
N /= 26;
}
Console.WriteLine(res);
}
}
#region "入力"
private static string NextInput = "";
private static int Int() => int.Parse(Str());
private static long Long() => long.Parse(Str());
private static float Float() => float.Parse(Str());
private static double Double() => double.Parse(Str());
private static string Str() {
var s = NextInput;
if (s == "")
s = Console.ReadLine();
var idx = s.IndexOf(' ');
if (idx >= 0) {
NextInput = s.Substring(idx + 1);
return s.Substring(0, idx);
}
NextInput = "";
return s;
}
#endregion
}
public static class EnumerablePlus {
///< summary>出力文字列に変換。</summary>
public static string MkString<T>(this IEnumerable<T> list) {
return list
.Aggregate(new System.Text.StringBuilder(),
(a, b) => ((a.Length > 0) ? a.Append(' ') : a).Append(b))
.ToString();
}
///< summary>添字付きfor。</summary>
public static void ForEachWithIdx<T>(this IEnumerable<T> list,
Action<T, long> a) {
long i = 0;
foreach (var item in list) {
a(item, i++);
}
}
///< summary>添字なしfor。</summary>
public static void ForEach<T>(this IEnumerable<T> list, Action<T> a) {
foreach (var item in list) {
a(item);
}
}
///< summary>指定回数デリゲートを呼び出す。</summary>
public static IEnumerable<T> Repeat<T>(long n, Func<T> f) {
for (long i = 0; i < n; i++) {
yield return f();
}
}
///< summary>条件付きMin。</summary>
public static T MinBy<T, U>(this IEnumerable<T> xs, Func<T, U> key)
where U : IComparable<U> {
return xs.Aggregate((a, b) => key(a).CompareTo(key(b)) <= 0 ? a : b);
}
///< summary>条件付きMax。</summary>
public static T MaxBy<T, U>(this IEnumerable<T> xs, Func<T, U> key)
where U : IComparable<U> {
return xs.Aggregate((a, b) => key(a).CompareTo(key(b)) >= 0 ? a : b);
}
///< summary>条件付きMax。複数の値を返す。</summary>
public static List<T> MaxByList<T, U>(this IEnumerable<T> xs, Func<T, U> key)
where U : IComparable<U> {
return xs.Aggregate(new List<T>(), (list, b) => {
if (list.Count == 0) {
list.Add(b);
return list;
}
var aa = key(list[0]);
var bb = key(b);
if (aa.CompareTo(bb) < 0)
list.Clear();
if (aa.CompareTo(bb) <= 0) {
list.Add(b);
return list;
}
return list;
});
}
///< summary>複数の値を返す。</summary>
public static List<T> MaxList<T>(this IEnumerable<T> xs)
where T : IComparable<T> { return xs.MaxByList(o => o); }
}
public static class MathPlus {
public static long Power(long x, long n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Power(x * x, n / 2);
return x * Power(x, n - 1);
}
///< summary>約数。順番は不定。</summary>
public static List<long> Divisor(long n) {
var list =
Prime(n)
.GroupBy(id => id)
.Select(pair => new { prime = pair.Key, power = pair.Count() })
.ToList();
var result = list.Aggregate(new List<long>(), (left, pair) => {
var list2 = Enumerable.Range(0, pair.power + 1)
.Aggregate(new List<long>(), (res, l) => {
var next = res.Count > 0 ? res.Last() * pair.prime : 1L;
res.Add(next);
return res;
});
if (left.Count == 0)
return list2.ToList();
return list2.SelectMany(l => left.Select(m => l * m)).ToList();
});
return result;
}
///< summary>順列の数。</summary>
public static long Permutation(long n, long r) => Factorial(n, r);
///< summary>組合せの数。</summary>
public static long Combination(long n, long r) {
if (r == 0)
return 1;
return Factorial(n, r) / Factorial(r);
}
///< summary>階乗。カウントも指定可能。</summary>
public static long Factorial(long a, long count = long.MaxValue) {
long res = 1;
for (long i = 0; a > 0 && i < count; i++) {
checked { res *= a; }
--a;
}
return res;
}
///< summary>素因数分解。昇順。</summary>
public static List<long> Prime(long a) {
var res = new List<long>();
var a2 = Math.Ceiling(Math.Sqrt(a));
for (long b = 2; b <= a2; ++b) {
while (a % b == 0) {
res.Add(b);
a = a / b;
a2 = Math.Ceiling(Math.Sqrt(a));
}
}
if (a > 1)
res.Add(a);
return res;
}
///< summary>最小公倍数。</summary>
public static long Lcm(IEnumerable<long> list) {
return list.Aggregate((a, b) => Lcm(a, b));
}
///< summary>最小公倍数。</summary>
public static long Lcm(long a, long b) { return checked(a * b) / Gcd(a, b); }
///< summary>最大公約数。</summary>
public static long Gcd(IEnumerable<long> list) {
return list.Aggregate((a, b) => Gcd(a, b));
}
///< summary>最大公約数。</summary>
public static long Gcd(long a, long b) {
if (a < b)
Gcd(b, a);
while (b != 0) {
var rem = a % b;
a = b;
b = rem;
}
return a;
}
///< summary>整数の切り上げ。</summary>
public static long Ceiling(long a, long b) => (a + (b - 1)) / b;
///< summary>区間内の合計。beginも1から?end含む。</summary>
public static ulong Sum(ulong begin, ulong end) {
var up = Sum(end);
var low = Sum(begin - 1);
return up - low;
}
///< summary>1からの合計。</summary>
public static ulong Sum(ulong end) => checked((end + 1) * end / 2);
}
public static class Util {
///< summary>リスト内の値を移動する。</summary>
public static void Move<T>(this IList<T> list, int from, int to) {
var item = list[from];
for (var idx = from; idx > to; --idx) {
list[idx] = list[idx - 1];
}
list[to] = item;
}
///< summary>最後の値か、デフォルト値を取得。</summary>
public static T LastOrValue<T>(this IList<T> list, T value) {
return list.Count > 0 ? list.Last() : value;
}
///< summary>辞書をMultiSetとして使うときのAdd。</summary>
public static void AddMulti<T>(this IDictionary<T, int> xs, T key) {
if (xs.ContainsKey(key))
xs[key]++;
else
xs.Add(key, 1);
}
///< summary>値を交換する。</summary>
public static void Swap(ref int x, ref int y) {
int temp = x;
x = y;
y = temp;
}
public static void Assert(bool cond) {
if (!cond)
throw new Exception();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
public class MainClass {
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput(), Console.Out.Encoding);
sw.AutoFlush = false;
Console.SetOut(sw);
if (args.Length > 0 && args[0] == "debug") {
var inputs = new[] { @"
1000000000000001
", @"
123456788
", @"
123456789
", @"
2
", @"
27
", @"
123456789
", @"
", @"
" };
foreach (var str in inputs) {
var text = str.TrimStart();
if (text.Length == 0)
continue;
var reader = new System.IO.StringReader(text);
Console.SetIn(reader);
Main2(args);
Console.WriteLine("----------------------------------");
}
} else
Main2(args);
Console.Out.Flush();
}
private static void Main2(string[] args) {
checked {
// var MAX = 1000000000000001L;
var N = long.Parse(Console.ReadLine());
var res = "";
while (N > 0) {
var s = N % 26;
if (s == 0)
s = 26;
res = (char)('a' + s - 1) + res;
N /= 26;
if (s == 26)
N -= 1;
}
Console.WriteLine(res);
}
}
#region "入力"
private static string NextInput = "";
private static int Int() => int.Parse(Str());
private static long Long() => long.Parse(Str());
private static float Float() => float.Parse(Str());
private static double Double() => double.Parse(Str());
private static string Str() {
var s = NextInput;
if (s == "")
s = Console.ReadLine();
var idx = s.IndexOf(' ');
if (idx >= 0) {
NextInput = s.Substring(idx + 1);
return s.Substring(0, idx);
}
NextInput = "";
return s;
}
#endregion
}
public static class EnumerablePlus {
///< summary>出力文字列に変換。</summary>
public static string MkString<T>(this IEnumerable<T> list) {
return list
.Aggregate(new System.Text.StringBuilder(),
(a, b) => ((a.Length > 0) ? a.Append(' ') : a).Append(b))
.ToString();
}
///< summary>添字付きfor。</summary>
public static void ForEachWithIdx<T>(this IEnumerable<T> list,
Action<T, long> a) {
long i = 0;
foreach (var item in list) {
a(item, i++);
}
}
///< summary>添字なしfor。</summary>
public static void ForEach<T>(this IEnumerable<T> list, Action<T> a) {
foreach (var item in list) {
a(item);
}
}
///< summary>指定回数デリゲートを呼び出す。</summary>
public static IEnumerable<T> Repeat<T>(long n, Func<T> f) {
for (long i = 0; i < n; i++) {
yield return f();
}
}
///< summary>条件付きMin。</summary>
public static T MinBy<T, U>(this IEnumerable<T> xs, Func<T, U> key)
where U : IComparable<U> {
return xs.Aggregate((a, b) => key(a).CompareTo(key(b)) <= 0 ? a : b);
}
///< summary>条件付きMax。</summary>
public static T MaxBy<T, U>(this IEnumerable<T> xs, Func<T, U> key)
where U : IComparable<U> {
return xs.Aggregate((a, b) => key(a).CompareTo(key(b)) >= 0 ? a : b);
}
///< summary>条件付きMax。複数の値を返す。</summary>
public static List<T> MaxByList<T, U>(this IEnumerable<T> xs, Func<T, U> key)
where U : IComparable<U> {
return xs.Aggregate(new List<T>(), (list, b) => {
if (list.Count == 0) {
list.Add(b);
return list;
}
var aa = key(list[0]);
var bb = key(b);
if (aa.CompareTo(bb) < 0)
list.Clear();
if (aa.CompareTo(bb) <= 0) {
list.Add(b);
return list;
}
return list;
});
}
///< summary>複数の値を返す。</summary>
public static List<T> MaxList<T>(this IEnumerable<T> xs)
where T : IComparable<T> { return xs.MaxByList(o => o); }
}
public static class MathPlus {
public static long Power(long x, long n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Power(x * x, n / 2);
return x * Power(x, n - 1);
}
///< summary>約数。順番は不定。</summary>
public static List<long> Divisor(long n) {
var list =
Prime(n)
.GroupBy(id => id)
.Select(pair => new { prime = pair.Key, power = pair.Count() })
.ToList();
var result = list.Aggregate(new List<long>(), (left, pair) => {
var list2 = Enumerable.Range(0, pair.power + 1)
.Aggregate(new List<long>(), (res, l) => {
var next = res.Count > 0 ? res.Last() * pair.prime : 1L;
res.Add(next);
return res;
});
if (left.Count == 0)
return list2.ToList();
return list2.SelectMany(l => left.Select(m => l * m)).ToList();
});
return result;
}
///< summary>順列の数。</summary>
public static long Permutation(long n, long r) => Factorial(n, r);
///< summary>組合せの数。</summary>
public static long Combination(long n, long r) {
if (r == 0)
return 1;
return Factorial(n, r) / Factorial(r);
}
///< summary>階乗。カウントも指定可能。</summary>
public static long Factorial(long a, long count = long.MaxValue) {
long res = 1;
for (long i = 0; a > 0 && i < count; i++) {
checked { res *= a; }
--a;
}
return res;
}
///< summary>素因数分解。昇順。</summary>
public static List<long> Prime(long a) {
var res = new List<long>();
var a2 = Math.Ceiling(Math.Sqrt(a));
for (long b = 2; b <= a2; ++b) {
while (a % b == 0) {
res.Add(b);
a = a / b;
a2 = Math.Ceiling(Math.Sqrt(a));
}
}
if (a > 1)
res.Add(a);
return res;
}
///< summary>最小公倍数。</summary>
public static long Lcm(IEnumerable<long> list) {
return list.Aggregate((a, b) => Lcm(a, b));
}
///< summary>最小公倍数。</summary>
public static long Lcm(long a, long b) { return checked(a * b) / Gcd(a, b); }
///< summary>最大公約数。</summary>
public static long Gcd(IEnumerable<long> list) {
return list.Aggregate((a, b) => Gcd(a, b));
}
///< summary>最大公約数。</summary>
public static long Gcd(long a, long b) {
if (a < b)
Gcd(b, a);
while (b != 0) {
var rem = a % b;
a = b;
b = rem;
}
return a;
}
///< summary>整数の切り上げ。</summary>
public static long Ceiling(long a, long b) => (a + (b - 1)) / b;
///< summary>区間内の合計。beginも1から?end含む。</summary>
public static ulong Sum(ulong begin, ulong end) {
var up = Sum(end);
var low = Sum(begin - 1);
return up - low;
}
///< summary>1からの合計。</summary>
public static ulong Sum(ulong end) => checked((end + 1) * end / 2);
}
public static class Util {
///< summary>リスト内の値を移動する。</summary>
public static void Move<T>(this IList<T> list, int from, int to) {
var item = list[from];
for (var idx = from; idx > to; --idx) {
list[idx] = list[idx - 1];
}
list[to] = item;
}
///< summary>最後の値か、デフォルト値を取得。</summary>
public static T LastOrValue<T>(this IList<T> list, T value) {
return list.Count > 0 ? list.Last() : value;
}
///< summary>辞書をMultiSetとして使うときのAdd。</summary>
public static void AddMulti<T>(this IDictionary<T, int> xs, T key) {
if (xs.ContainsKey(key))
xs[key]++;
else
xs.Add(key, 1);
}
///< summary>値を交換する。</summary>
public static void Swap(ref int x, ref int y) {
int temp = x;
x = y;
y = temp;
}
public static void Assert(bool cond) {
if (!cond)
throw new Exception();
}
}
|
[["+", 0, 200, 0, 212, 0, 297, 0, 229, 0, 258], ["+", 0, 200, 0, 212, 0, 297, 0, 229, 0, 21], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 196, 0, 52, 8, 196, 0, 197, 0, 35], ["+", 0, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 0, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 110], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203]]
| 8
| 1,848
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() => new Program().Solve();
void Solve() {
var n = ReadLong();
var s = "";
while (n != 0) {
var t = (n - 1) % 26;
s = (char)(t + 'a') + s;
n = n / 26;
}
Console.WriteLine(s);
}
#region Console.Read 関係
long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
long ReadLong() => long.Parse(Console.ReadLine());
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() => new Program().Solve();
void Solve() {
var n = ReadLong();
var s = "";
while (true) {
n--;
var t = n % 26;
s = (char)(t + 'a') + s;
if (n <= 25)
break;
n = n / 26;
}
Console.WriteLine(s);
}
#region Console.Read 関係
long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(),
long.Parse);
long ReadLong() => long.Parse(Console.ReadLine());
#endregion
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94]]
| 8
| 147
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = decimal.Parse(Console.ReadLine()) - 1;
var list = new List<decimal>();
var i = 1;
var current = N;
while (true) {
if ((i != 1 && current / 26 > 1) || (i == 1 && current / 26 >= 1)) {
if (i == 1 || current % 26 != 0) {
list.Add(current % 26);
} else {
list.Add(26);
}
current = (current - (current % 26)) / 26;
} else {
if (i == 1 || current % 26 != 0) {
list.Add(current % 26);
} else {
list.Add(26);
}
break;
}
i++;
}
var ans = "";
for (var j = list.Count - 1; j > -1; j--) {
var n = 97;
if (j != 0) {
n -= 1;
}
ans += (char)(list[j] + n);
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = decimal.Parse(Console.ReadLine()) - 1;
var list = new List<decimal>();
var i = 1;
var current = N;
while (true) {
if ((i != 1 && current / 26 > 1) || (i == 1 && current / 26 >= 1)) {
if (i == 1 || current % 26 != 0) {
list.Add(current % 26);
} else {
list.Add(26);
}
var div = (current % 26 == 0 ? 26 : current % 26);
if (i == 1) {
div = current % 26;
}
current = (current - div) / 26;
} else {
if (i == 1 || current % 26 != 0) {
list.Add(current % 26);
} else {
list.Add(26);
}
break;
}
i++;
}
var ans = "";
for (var j = list.Count - 1; j > -1; j--) {
var n = 97;
if (j != 0) {
n -= 1;
}
ans += (char)(list[j] + n);
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 64, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["-", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 0, 23, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 23, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 0, 212, 0, 23, 0, 41, 15, 16, 17, 60], ["+", 0, 212, 0, 23, 0, 41, 15, 16, 12, 203], ["+", 0, 200, 0, 212, 0, 23, 0, 41, 0, 101], ["+", 0, 200, 0, 212, 0, 23, 0, 41, 64, 203], ["+", 0, 200, 0, 212, 0, 23, 0, 41, 0, 102], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
| 8
| 260
| 33
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
long n = long.Parse(input[0]);
char a = 'a';
List<char> nameInv = new List<char>();
long test = n;
while (test > 0) {
long idx = test % 26;
if (idx == 0)
idx = 26;
nameInv.Add((char)((long)a - 1 + idx));
if (idx == 26)
break;
test /= 26;
}
int len = nameInv.Count;
char[] name = new char[len];
for (int i = 0; i < len; i++)
name[i] = nameInv[len - 1 - i];
Console.WriteLine(name);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
long n = long.Parse(input[0]);
char a = 'a';
List<char> nameInv = new List<char>();
long test = n;
while (true) {
long tmp1 = test % 26;
if (tmp1 == 0)
tmp1 = 26;
nameInv.Add((char)(tmp1 - 1 + (long)a));
test -= tmp1;
if (test == 0)
break;
test /= 26;
}
int len = nameInv.Count;
char[] name = new char[len];
for (int i = 0; i < len; i++)
name[i] = nameInv[len - 1 - i];
Console.WriteLine(name);
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 211, 0, 146], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 74, 51, 23, 0, 16, 31, 16, 31, 22], ["+", 0, 74, 51, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 74, 51, 23, 0, 16, 31, 16, 12, 203], ["+", 0, 28, 0, 74, 51, 23, 0, 16, 17, 72], ["-", 0, 74, 51, 23, 0, 16, 31, 16, 17, 33], ["-", 0, 74, 51, 23, 0, 16, 31, 16, 12, 203], ["-", 0, 28, 0, 74, 51, 23, 0, 16, 17, 72], ["-", 0, 28, 0, 74, 51, 23, 0, 16, 12, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 191
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6 {
class Program {
static string alfa = "abcdefghijklmnopqrstuvwxyz";
static void Main(string[] args) {
var ret = string.Empty;
var num = c2i(RL()) - 1;
var ls = new List<int>();
if (num == 0) {
ret = "a";
}
while (num >= 0) {
ls.Add((int)(num % 26));
num = num / 26 - 1;
}
for (int i = ls.Count; i > 0; i--) {
ret += alfa[ls[i - 1]];
}
Console.WriteLine(ret);
Console.ReadLine();
}
static IEnumerable<Int64> RL2IE() { return spr(RL()).Select(x => c2i(x)); }
static string RL() { return Console.ReadLine().Trim(); }
static IEnumerable<string> spr(string s) { return s.Split(' '); }
static Int64 c2i(string c) { return Int64.Parse(c); }
// static double c2d(string c) { return double.Parse(c); }
static string bool2ret(bool b) { return b ? "Yes" : "No"; }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication6 {
class Program {
static string alfa = "abcdefghijklmnopqrstuvwxyz";
static void Main(string[] args) {
var ret = string.Empty;
var num = c2i(RL()) - 1;
var ls = new List<int>();
while (num >= 0) {
ls.Add((int)(num % 26));
num = num / 26 - 1;
}
for (int i = ls.Count; i > 0; i--) {
ret += alfa[ls[i - 1]];
}
Console.WriteLine(ret);
Console.ReadLine();
}
static IEnumerable<Int64> RL2IE() { return spr(RL()).Select(x => c2i(x)); }
static string RL() { return Console.ReadLine().Trim(); }
static IEnumerable<string> spr(string s) { return s.Split(' '); }
static Int64 c2i(string c) { return Int64.Parse(c); }
// static double c2d(string c) { return double.Parse(c); }
static string bool2ret(bool b) { return b ? "Yes" : "No"; }
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 62], ["-", 64, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 277
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
long n = sc.NextLong();
string answer = "";
while (true) {
long mod = n % 26;
answer = ((char)('a' + mod - 1)).ToString() + answer;
n /= 26;
if (n == 0) {
break;
}
}
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 n = sc.NextLong();
string answer = "";
while (true) {
long mod = n % 26;
char c = mod == 0 ? 'z' : (char)('a' + mod - 1);
answer = c.ToString() + answer;
n -= mod == 0 ? 26 : mod;
n /= 26;
if (n == 0) {
break;
}
}
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, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 12, 16, 31, 213, 63, 214, 205, 23, 0, 24], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 200, 0, 212, 0, 41, 64, 252, 0, 104], ["+", 0, 200, 0, 212, 0, 41, 64, 252, 0, 253], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["-", 63, 214, 205, 23, 0, 74, 51, 23, 0, 25], ["+", 8, 196, 0, 52, 8, 196, 0, 197, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 11, 12, 16, 31, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 17, 60], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 75, 22]]
| 8
| 406
| 27
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProblemC {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
long alphabetNum = 26;
long temp = 1;
var firstNum = N % 26;
var res = firstNum == 0 ? "z" : ((char)(firstNum + 96)).ToString();
var resAsNum = new long[11];
int i = 1;
for (; i < 11; i++) {
temp *= 26;
if (N - temp <= 0)
break;
else {
resAsNum[i] = ((N - temp) / temp) % alphabetNum;
}
}
for (int j = 1; j < i; j++) {
res = ((char)(resAsNum[j] + 97)).ToString() + res;
}
Console.WriteLine(res);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProblemC {
class Program {
static void Main(string[] args) {
var N = long.Parse(Console.ReadLine());
long alphabetNum = 26;
long numPow = 1;
long temp = 0;
var firstNum = N % 26;
var res = firstNum == 0 ? "z" : ((char)(firstNum + 96)).ToString();
var resAsNum = new long[11];
int i = 1;
for (; i < 11; i++) {
numPow *= 26;
temp += numPow;
if (N - temp <= 0)
break;
else {
resAsNum[i] = ((N - temp - 1) / numPow) % alphabetNum;
}
}
for (int j = 1; j < i; j++) {
res = ((char)(resAsNum[j] + 97)).ToString() + res;
}
Console.WriteLine(res);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 22]]
| 8
| 208
| 17
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderMake.ABC171 {
class ABC171C {
static void Main(string[] args) {
var n = long.Parse(Console.ReadLine());
List<char> ans = new List<char>();
String ret = "";
while (n != 0) {
ans.Add(alphNum(n));
n = n / 26;
}
for (int i = 0; i < ans.Count; i++) {
ret += ans[ans.Count - i - 1];
}
Console.WriteLine(ret);
}
static char alphNum(long num) {
long amari = num % 26;
if (amari == 0) {
amari = 26;
}
return (char)(96 + amari);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderMake.ABC171 {
class ABC171C {
static void Main(string[] args) {
var n = long.Parse(Console.ReadLine());
List<char> ans = new List<char>();
String ret = "";
while (n != 0) {
n--;
ans.Add(alphNum(n));
n = n / 26;
}
for (int i = 0; i < ans.Count; i++) {
ret += ans[ans.Count - i - 1];
}
Console.WriteLine(ret);
}
static char alphNum(long num) {
long amari = num % 26;
return (char)(97 + amari);
}
}
}
|
[["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 37, 0, 74, 51, 23, 0, 16, 31, 203], ["+", 0, 37, 0, 74, 51, 23, 0, 16, 31, 203]]
| 8
| 170
| 17
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program {
public static void Main() {
long N = long.Parse(Console.ReadLine());
long num = 26;
String ans = "";
while (N > 0) {
int x = (int)(N % num - 1);
char temp = (char)('a' + x);
ans = temp + ans;
N /= num;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program {
public static void Main() {
long N = long.Parse(Console.ReadLine());
long num = 26;
String ans = "";
while (N > 0) {
N = N - 1;
long x = (long)(N % num);
char temp = (char)('a' + x);
ans = temp + ans;
N = N / num;
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["-", 0, 212, 0, 74, 51, 23, 0, 16, 17, 33], ["-", 0, 212, 0, 74, 51, 23, 0, 16, 12, 203], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85]]
| 8
| 110
| 16
|
using System;
using System.Collections;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
string ans = "";
while (N > 0) {
ans = DecToLetter(N % 26) + ans;
N -= N % 26;
N /= 26;
}
Console.WriteLine(ans);
}
static string DecToLetter(long i) { return ((char)(96 + i)).ToString(); }
}
// dotnet run --project test
|
using System;
using System.Collections;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
string ans = "";
while (N > 0) {
ans = DecToLetter((N - 1) % 26 + 1) + ans;
N -= (N - 1) % 26 + 1;
N /= 26;
}
Console.WriteLine(ans);
}
static string DecToLetter(long i) { return ((char)(96 + i)).ToString(); }
}
// dotnet run --project test
|
[["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 24], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 11, 12, 16, 31, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
| 8
| 112
| 12
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var n = IO.RLong;
var a = new List<long>();
while (n > 0) {
long work = 0;
work = n % 26;
a.Add(work);
n -= work;
n /= 26;
}
string ans = "";
a.Reverse();
for (int i = 0; i < a.Count; i++) {
char work = (char)('a' + a[i] - 1);
ans += work;
}
WriteLine(ans);
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static StreamWriter sw =
new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
try {
SetOut(sw);
Solve.Answer();
Out.Flush();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var n = IO.RLong;
var a = new List<long>();
while (n > 0) {
long work = 0;
work = n % 26;
if (work == 0)
work = 26;
a.Add(work);
n -= work;
n /= 26;
}
string ans = "";
a.Reverse();
for (int i = 0; i < a.Count; i++) {
char work = (char)('a' + a[i] - 1);
ans += work;
}
WriteLine(ans);
}
}
public class IO {
#region Input
public static int RInt => int.Parse(ReadLine());
public static long RLong => long.Parse(ReadLine());
public static double RDouble => double.Parse(ReadLine());
public static string[] RSString => ReadLine().Split();
public static int[] RSInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToArray();
public static long[] RSLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToArray();
public static double[] RSDouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToArray();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES"
: "NO");
#endregion
}
public class Mod {
#region
private readonly static long M = 1000000007;
public static long Add(long a, long b) => (a * b) % M;
public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M
: (a - b) % M + M;
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
}
|
[["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 574
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_20190707_1 {
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
List<long> name = new List<long>();
do {
name.Add(N % 26);
N = N / 26;
} while (N > 0);
name.Reverse();
string answer = string.Empty;
for (int i = 0; i < name.Count(); i++) {
answer += (char)('a' + name[i] - 1);
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder_20190707_1 {
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
List<long> name = new List<long>();
do {
if (N % 26 != 0) {
name.Add(N % 26);
N = N / 26;
} else {
name.Add(26);
N = N / 26 - 1;
}
} while (N > 0);
name.Reverse();
string answer = string.Empty;
for (int i = 0; i < name.Count(); i++) {
answer += (char)('a' + name[i] - 1);
}
Console.WriteLine(answer);
}
}
}
|
[["+", 8, 196, 0, 82, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 82, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 82, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 82, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 82, 8, 196, 0, 57, 0, 25], ["+", 0, 82, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 0, 82, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 82, 8, 196, 0, 57, 0, 95], ["+", 0, 82, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 82, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 157
| 28
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
long num = n;
int sp = 26;
char[] ch = getChar(26);
string result = "";
long amari = 0;
while (true) {
if (num <= sp) {
result = ch[num - 1] + result;
break;
}
amari = num % sp;
num = num / sp;
result = ch[amari - 1] + result;
}
Console.WriteLine(result);
Console.Out.Flush();
}
/// <summary>
/// 文字テーブルを作成します。
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
private static char[] getChar(int count) {
char[] result = new char[count];
for (int i = 0; i < count; i++) {
result[i] = (char)('a' + ((char)i));
}
return result;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
int sp = 26;
char[] ch = getChar(26);
string result = "";
long amari = 0;
while (true) {
if (n <= sp) {
result = ch[n - 1] + result;
break;
}
amari = n % sp == 0 ? 26 : n % sp;
n = (n - 1) / sp;
result = ch[amari - 1] + result;
}
Console.WriteLine(result);
Console.Out.Flush();
}
/// <summary>
/// 文字テーブルを作成します。
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
private static char[] getChar(int count) {
char[] result = new char[count];
for (int i = 0; i < count; i++) {
result[i] = (char)('a' + ((char)i));
}
return result;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 11, 12, 41, 15, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 17, 60], ["+", 0, 1, 0, 11, 12, 41, 15, 16, 12, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 64, 203], ["+", 8, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 0, 1, 0, 11, 12, 41, 75, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 41, 75, 16, 17, 109], ["+", 0, 1, 0, 11, 12, 41, 75, 16, 12, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 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
| 257
| 27
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Solve {
static public int mod = 1000000007;
static public string al = "abcdefghijklmnopqrstuvwxyz";
public static void Main() {
// •ûj
//
// WriteLine(26*27);
var n = rlong();
var list = new List<char>();
while (n > 0) {
var a = (int)(n % 26);
list.Add(al[a - 1]);
n -= a;
n /= 26;
}
list.Reverse();
WriteLine(string.Join("", list));
/*
for(int i=0;i<5;i++){
var a = rlong();
while(a > 0){
var b = (int)(a%26-1);
Write(al[b]);
a -= b+1;
a/=26;
}
WriteLine();
}
*/
}
public static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
if (n < r)
return 0;
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static int square2(int a, int b) {
long output = 1;
var list = new List<long>();
int sh = 1;
long n = a;
list.Add(a);
while (sh < b) {
sh *= 2;
n = n * n % mod;
list.Add(n);
}
for (int i = list.Count - 1; i >= 0; i--) {
if (b > sh) {
b -= sh;
sh /= 2;
output = output * list[i] % mod;
}
}
return (int)output;
}
//Šeí“Çæ
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static 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;
}
// -----------------------------
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); }
static void WriteArray(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Solve {
static public int mod = 1000000007;
static public string al = "abcdefghijklmnopqrstuvwxyz";
public static void Main() {
// •ûj
//
// WriteLine(26*27);
var n = rlong();
var list = new List<char>();
while (n > 0) {
var a = (int)(n % 26);
// WriteLine(a);
if (a == 0) {
a += 26;
}
list.Add(al[a - 1]);
n -= a;
n /= 26;
}
list.Reverse();
WriteLine(string.Join("", list));
/*
for(int i=0;i<5;i++){
var a = rlong();
while(a > 0){
var b = (int)(a%26-1);
Write(al[b]);
a -= b+1;
a/=26;
}
WriteLine();
}
*/
}
public static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
if (n < r)
return 0;
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static int square2(int a, int b) {
long output = 1;
var list = new List<long>();
int sh = 1;
long n = a;
list.Add(a);
while (sh < b) {
sh *= 2;
n = n * n % mod;
list.Add(n);
}
for (int i = list.Count - 1; i >= 0; i--) {
if (b > sh) {
b -= sh;
sh /= 2;
output = output * list[i] % mod;
}
}
return (int)output;
}
//Šeí“Çæ
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static 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;
}
// -----------------------------
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); }
static void WriteArray(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
}
|
[["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,184
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
class c {
public static void Main() {
long n = long.Parse(Console.ReadLine());
String ans = "";
while (n > 0) {
long a = n % 26;
if (a == 0) {
a = 26;
}
ans = (char)('a' + a - 1) + ans;
n /= 26;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class c {
public static void Main() {
long n = long.Parse(Console.ReadLine());
String ans = "";
while (n > 0) {
long a = n % 26;
if (a == 0)
a = 26;
ans = (char)('a' + a - 1) + ans;
n /= 26;
if (a == 26)
n--;
// Console.WriteLine(n);
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 52, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 68]]
| 8
| 102
| 11
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
using System.IO.Pipes;
using System.Threading;
using System.Net;
class Program {
#region Reader
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static int mod = (int)Pow(10, 9) + 7;
public static long GetInv(long a, long mod = 1000000007) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod = 1000000007) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
/// <summary>
/// 最小公倍数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
/// <summary>
/// 最大公約数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public struct MyStruct {
public MyStruct(long a, long b) {
A = a;
B = b;
}
public long A;
public long B;
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class PriorityQueue<TKey, TValue> : IEnumerable<TValue> {
private readonly List<KeyValuePair<TKey, TValue>> _data =
new List<KeyValuePair<TKey, TValue>>();
private readonly bool _isDescending;
private readonly Func<TValue, TKey> _keySelector;
private readonly IComparer<TKey> _keyComparer;
public PriorityQueue(Func<TValue, TKey> keySelector,
bool isDescending = true)
: this(keySelector, Comparer<TKey>.Default, isDescending) {}
public PriorityQueue(Func<TValue, TKey> keySelector,
IComparer<TKey> keyComparer,
bool isDescending = true) {
_keySelector = keySelector;
_keyComparer = keyComparer;
_isDescending = isDescending;
}
public void Enqueue(TValue item) {
_data.Add(new KeyValuePair<TKey, TValue>(_keySelector(item), item));
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex].Key, _data[parentIndex].Key) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public TValue Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild].Key, _data[childIndex].Key) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex].Key, _data[childIndex].Key) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem.Value;
}
public TValue Peek() { return _data[0].Value; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(TKey a, TKey b) {
return _isDescending ? _keyComparer.Compare(b, a)
: _keyComparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<TValue> GetEnumerator() {
return _data.Select(r => r.Value).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
static bool Divisor(long N) {
int max = (int)Math.Sqrt(N);
for (int i = 1; i < max; i++) {
if (N % i == 0) {
if (b[i])
return false;
if (b[N / i])
return false;
}
}
if (N % max == 0) {
if (N / max == max) {
if (b[max])
return false;
} else {
if (b[max])
return false;
if (b[N / max])
return false;
}
}
return true;
}
static bool[] b = new bool[3000000];
static void Main() {
long N = ReadLong;
List<char> nstring = new List<char>();
long r = 1; // 余り
long q = N; // 商
int n = 26;
// 商が0になるまでループ
while (q > 0) {
r = q % n;
nstring.Add((char)(96 + r));
q = q / n;
}
nstring.Reverse();
WriteLine(string.Join("", nstring));
}
public static Dictionary<int, int> PrimeFactors(int n) {
int i = 2;
int tmp = n;
Dictionary<int, int> d = new Dictionary<int, int>();
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
if (d.ContainsKey(i))
d[i]++;
else
d.Add(i, 1);
} else {
i++;
}
}
if (tmp != 1) {
if (d.ContainsKey(tmp))
d[tmp]++;
else
d.Add(tmp, 1);
}
return d;
}
}
|
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
using System.IO.Pipes;
using System.Threading;
using System.Net;
class Program {
#region Reader
static string ReadStr => Console.ReadLine();
static string[] ReadStrs => Console.ReadLine().Split(' ');
static int ReadInt => Convert.ToInt32(Console.ReadLine());
static int[] ReadInts =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
static long ReadLong => Convert.ToInt64(Console.ReadLine());
static long[] ReadLongs =>
Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
static long[,] ReLongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = ReadLongs;
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
static Tuple<string, string>[] ReTupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = ReadStrs;
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<long, long>[] ReTupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<int, int>[] ReadTupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = ReadInts;
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
static Tuple<double, double>[] ReTupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = ReadLongs;
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
static Dictionary<int, HashSet<int>> ReAdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = ReadInts;
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
#endregion
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static int mod = (int)Pow(10, 9) + 7;
public static long GetInv(long a, long mod = 1000000007) {
return PowerMod(a, mod - 2, mod);
}
public static long Combination(long a, long b, long mod = 1000000007) {
if (b < 0 || b > a)
return 0;
if (b > a / 2)
b = a - b;
long numerator = Factorial(a, mod);
long denominator = (Factorial(b, mod) * Factorial(a - b, mod)) % mod;
return (numerator * GetInv(denominator, mod)) % mod;
}
public static long Factorial(long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return 1;
long ans = n;
for (int i = 2; i < n; i++) {
ans = (ans * i) % mod;
}
return ans;
}
private static long PowerMod(long a, long n, long mod = 1000000007) {
if (n == 0)
return 1;
if (n == 1)
return a;
long p = PowerMod(a, n / 2, mod);
if (n % 2 == 1)
return ((p * p) % mod * a) % mod;
else
return (p * p) % mod;
}
/// <summary>
/// 最小公倍数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
/// <summary>
/// 最大公約数
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
if (a < b)
// 引数を入替えて自分を呼び出す
return Gcd(b, a);
while (b != 0) {
var remainder = a % b;
a = b;
b = remainder;
}
return a;
}
public struct MyStruct {
public MyStruct(long a, long b) {
A = a;
B = b;
}
public long A;
public long B;
}
public class PriorityQueue<T> : IEnumerable<T> {
private readonly List<T> _data = new List<T>();
private readonly IComparer<T> _comparer;
private readonly bool _isDescending;
public PriorityQueue(IComparer<T> comparer, bool isDescending = true) {
_comparer = comparer;
_isDescending = isDescending;
}
public PriorityQueue(Comparison<T> comparison, bool isDescending = true)
: this(Comparer<T>.Create(comparison), isDescending) {}
public PriorityQueue(bool isDescending = true)
: this(Comparer<T>.Default, isDescending) {}
public void Enqueue(T item) {
_data.Add(item);
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex], _data[parentIndex]) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public T Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild], _data[childIndex]) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex], _data[childIndex]) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem;
}
public T Peek() { return _data[0]; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(T a, T b) {
return _isDescending ? _comparer.Compare(b, a) : _comparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<T> GetEnumerator() { return _data.GetEnumerator(); }
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public class PriorityQueue<TKey, TValue> : IEnumerable<TValue> {
private readonly List<KeyValuePair<TKey, TValue>> _data =
new List<KeyValuePair<TKey, TValue>>();
private readonly bool _isDescending;
private readonly Func<TValue, TKey> _keySelector;
private readonly IComparer<TKey> _keyComparer;
public PriorityQueue(Func<TValue, TKey> keySelector,
bool isDescending = true)
: this(keySelector, Comparer<TKey>.Default, isDescending) {}
public PriorityQueue(Func<TValue, TKey> keySelector,
IComparer<TKey> keyComparer,
bool isDescending = true) {
_keySelector = keySelector;
_keyComparer = keyComparer;
_isDescending = isDescending;
}
public void Enqueue(TValue item) {
_data.Add(new KeyValuePair<TKey, TValue>(_keySelector(item), item));
var childIndex = _data.Count - 1;
while (childIndex > 0) {
var parentIndex = (childIndex - 1) / 2;
if (Compare(_data[childIndex].Key, _data[parentIndex].Key) >= 0)
break;
Swap(childIndex, parentIndex);
childIndex = parentIndex;
}
}
public TValue Dequeue() {
var lastIndex = _data.Count - 1;
var firstItem = _data[0];
_data[0] = _data[lastIndex];
_data.RemoveAt(lastIndex--);
var parentIndex = 0;
while (true) {
var childIndex = parentIndex * 2 + 1;
if (childIndex > lastIndex)
break;
var rightChild = childIndex + 1;
if (rightChild <= lastIndex &&
Compare(_data[rightChild].Key, _data[childIndex].Key) < 0)
childIndex = rightChild;
if (Compare(_data[parentIndex].Key, _data[childIndex].Key) <= 0)
break;
Swap(parentIndex, childIndex);
parentIndex = childIndex;
}
return firstItem.Value;
}
public TValue Peek() { return _data[0].Value; }
private void Swap(int a, int b) {
var tmp = _data[a];
_data[a] = _data[b];
_data[b] = tmp;
}
private int Compare(TKey a, TKey b) {
return _isDescending ? _keyComparer.Compare(b, a)
: _keyComparer.Compare(a, b);
}
public int Count => _data.Count;
public IEnumerator<TValue> GetEnumerator() {
return _data.Select(r => r.Value).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
static bool Divisor(long N) {
int max = (int)Math.Sqrt(N);
for (int i = 1; i < max; i++) {
if (N % i == 0) {
if (b[i])
return false;
if (b[N / i])
return false;
}
}
if (N % max == 0) {
if (N / max == max) {
if (b[max])
return false;
} else {
if (b[max])
return false;
if (b[N / max])
return false;
}
}
return true;
}
static bool[] b = new bool[3000000];
static void Main() {
long N = ReadLong;
List<char> nstring = new List<char>();
long r = 1; // 余り
long q = N; // 商
int n = 26;
// 商が0になるまでループ
while (q > 0) {
r = (q - 1) % n;
nstring.Add((char)(97 + r));
q = (q - 1) / n;
}
nstring.Reverse();
WriteLine(string.Join("", nstring));
}
public static Dictionary<int, int> PrimeFactors(int n) {
int i = 2;
int tmp = n;
Dictionary<int, int> d = new Dictionary<int, int>();
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
if (d.ContainsKey(i))
d[i]++;
else
d.Add(i, 1);
} else {
i++;
}
}
if (tmp != 1) {
if (d.ContainsKey(tmp))
d[tmp]++;
else
d.Add(tmp, 1);
}
return d;
}
}
|
[["+", 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], ["-", 0, 28, 0, 74, 51, 23, 0, 16, 31, 203], ["+", 0, 28, 0, 74, 51, 23, 0, 16, 31, 203]]
| 8
| 2,537
| 10
|
using System;
using System.Collections.Generic;
using System.Text;
namespace abc171_c {
class Program {
static void Main(string[] args) {
var N = CIn.ReadLong();
var sb = new StringBuilder();
while (N > 0) {
var c = (char)((N - 1) % 26 + 'a');
sb.Insert(0, c);
N /= 26;
}
Console.WriteLine(sb.ToString());
}
}
static class CIn {
private static readonly Queue<string> fieldBuffer = new Queue<string>();
public static string Read() {
if (fieldBuffer.Count == 0) {
foreach (var field in Console.ReadLine().Split()) {
fieldBuffer.Enqueue(field);
}
}
return fieldBuffer.Dequeue();
}
public static int ReadInt() => int.Parse(Read());
public static long ReadLong() => long.Parse(Read());
public static double ReadDouble() => double.Parse(Read());
public static string[] ReadStringArray(int n) {
var array = new string[n];
for (var i = 0; i < n; i++) {
array[i] = Read();
}
return array;
}
public static int[] ReadIntArray(int n) {
var array = new int[n];
for (var i = 0; i < n; i++) {
array[i] = ReadInt();
}
return array;
}
public static long[] ReadLongArray(int n) {
var array = new long[n];
for (var i = 0; i < n; i++) {
array[i] = ReadLong();
}
return array;
}
public static double[] ReadDoubleArray(int n) {
var array = new double[n];
for (var i = 0; i < n; i++) {
array[i] = ReadDouble();
}
return array;
}
public static char[,] ReadCharMatrix(int h, int w) {
var array = new char[h, w];
for (var i = 0; i < h; i++) {
var l = Console.ReadLine().ToCharArray();
for (var j = 0; j < w; j++) {
array[i, j] = l[j];
}
}
return array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace abc171_c {
class Program {
static void Main(string[] args) {
var N = CIn.ReadLong();
var sb = new StringBuilder();
while (N > 0) {
N -= 1;
var c = (char)(N % 26 + 'a');
sb.Insert(0, c);
N /= 26;
}
Console.WriteLine(sb.ToString());
}
}
static class CIn {
private static readonly Queue<string> fieldBuffer = new Queue<string>();
public static string Read() {
if (fieldBuffer.Count == 0) {
foreach (var field in Console.ReadLine().Split()) {
fieldBuffer.Enqueue(field);
}
}
return fieldBuffer.Dequeue();
}
public static int ReadInt() => int.Parse(Read());
public static long ReadLong() => long.Parse(Read());
public static double ReadDouble() => double.Parse(Read());
public static string[] ReadStringArray(int n) {
var array = new string[n];
for (var i = 0; i < n; i++) {
array[i] = Read();
}
return array;
}
public static int[] ReadIntArray(int n) {
var array = new int[n];
for (var i = 0; i < n; i++) {
array[i] = ReadInt();
}
return array;
}
public static long[] ReadLongArray(int n) {
var array = new long[n];
for (var i = 0; i < n; i++) {
array[i] = ReadLong();
}
return array;
}
public static double[] ReadDoubleArray(int n) {
var array = new double[n];
for (var i = 0; i < n; i++) {
array[i] = ReadDouble();
}
return array;
}
public static char[,] ReadCharMatrix(int h, int w) {
var array = new char[h, w];
for (var i = 0; i < h; i++) {
var l = Console.ReadLine().ToCharArray();
for (var j = 0; j < w; j++) {
array[i, j] = l[j];
}
}
return array;
}
}
}
|
[["+", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["+", 0, 52, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["-", 0, 200, 0, 212, 0, 74, 51, 23, 0, 24], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["-", 51, 23, 0, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 505
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder.Abc171 {
class C {
public static void Main() {
var n = long.Parse(Console.ReadLine());
var ans = new List<char>();
while (n > 0) {
int a = (int)((n - 1) % 26);
ans.Add((char)(a + 'a'));
n /= 26;
}
ans.Reverse();
Console.WriteLine(new string(ans.ToArray()));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder.Abc171 {
class C {
public static void Main() {
var n = long.Parse(Console.ReadLine());
var ans = new List<char>();
while (n > 0) {
int a = (int)((n - 1) % 26);
ans.Add((char)(a + 'a'));
n = (n - 1) / 26;
}
ans.Reverse();
Console.WriteLine(new string(ans.ToArray()));
}
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 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, 17, 85]]
| 8
| 123
| 8
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace D {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var Q = int.Parse(Console.ReadLine());
var dict = new Dictionary<long, long>();
var answer = 0L;
for (var i = 0; i < A.Length; i++) {
if (dict.ContainsKey(A[i]))
dict[A[i]]++;
else
dict[A[i]] = 1L;
answer += A[i];
}
for (var i = 0; i < Q; i++) {
var BC =
Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var B = BC[0];
var C = BC[1];
if (!dict.ContainsKey(B))
dict[B] = 0L;
if (!dict.ContainsKey(C))
dict[C] = 0L;
dict[C] += dict[B];
answer += (C - B) * dict[B];
Console.WriteLine(answer);
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace D {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var N = int.Parse(Console.ReadLine());
var A = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var Q = int.Parse(Console.ReadLine());
var dict = new Dictionary<long, long>();
var answer = 0L;
for (var i = 0; i < A.Length; i++) {
if (dict.ContainsKey(A[i]))
dict[A[i]]++;
else
dict[A[i]] = 1L;
answer += A[i];
}
for (var i = 0; i < Q; i++) {
var BC =
Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var B = BC[0];
var C = BC[1];
if (!dict.ContainsKey(B))
dict[B] = 0L;
if (!dict.ContainsKey(C))
dict[C] = 0L;
dict[C] += dict[B];
answer += (C - B) * dict[B];
dict.Remove(B);
Console.WriteLine(answer);
}
}
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 351
| 7
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader( "stdin.txt"
// );System.Console.SetIn( exStdIn );
int n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
long sm = 0;
var cnt = new int[a.Max() + 1];
for (int i = 0; i < n; i++) {
sm += a[i];
cnt[a[i]]++;
}
int q = int.Parse(Console.ReadLine());
for (int i = 0; i < q; i++) {
var bc = Console.ReadLine().Split().Select(int.Parse).ToArray();
int b = bc[0];
int c = bc[1];
sm += (c - b) * cnt[b];
cnt[c] += cnt[b];
cnt[b] = 0;
Console.WriteLine(sm);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
class Program {
static void Main(string[] args) {
// var exStdIn = new System.IO.StreamReader( "stdin.txt"
// );System.Console.SetIn( exStdIn );
int n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
long sm = 0;
var cnt = new int[100005];
for (int i = 0; i < n; i++) {
sm += a[i];
cnt[a[i]]++;
}
int q = int.Parse(Console.ReadLine());
for (int i = 0; i < q; i++) {
var bc = Console.ReadLine().Split().Select(int.Parse).ToArray();
int b = bc[0];
int c = bc[1];
sm += (c - b) * cnt[b];
cnt[c] += cnt[b];
cnt[b] = 0;
Console.WriteLine(sm);
}
}
}
|
[["-", 225, 226, 0, 16, 31, 213, 63, 214, 205, 22], ["-", 225, 226, 0, 16, 31, 213, 63, 214, 0, 131], ["-", 225, 226, 0, 16, 31, 213, 63, 214, 141, 22], ["-", 225, 226, 0, 16, 31, 213, 3, 4, 0, 24], ["-", 225, 226, 0, 16, 31, 213, 3, 4, 0, 25], ["-", 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
| 274
| 8
|
using System;
using System.Collections.Generic;
public class Program {
public static Int64 sum(Dictionary<String, Int64> nums) {
Int64 sum = 0;
foreach (KeyValuePair<String, Int64> item in nums) {
sum += item.Value * Convert.ToInt64(item.Key);
}
return sum;
}
public static void Main(String[] args) {
var numbers = new Dictionary<String, Int64>();
Int64 numberOfElements = Convert.ToInt64(Console.ReadLine());
foreach (String x in Console.ReadLine().Split(' ')) {
if (numbers.ContainsKey(x)) {
numbers[x] += 1;
} else {
numbers.Add(x, 1);
}
}
Int64 numOfOperations = Convert.ToInt64(Console.ReadLine());
for (Int64 i = 0; i < numOfOperations; ++i) {
String[] x = Console.ReadLine().Split(' ');
if (numbers.ContainsKey(x[0])) {
Console.WriteLine((Convert.ToInt64(x[1]) - Convert.ToInt64(x[0])) *
numbers[x[0]] +
sum(numbers));
if (numbers.ContainsKey(x[1]))
numbers[x[1]] += numbers[x[0]];
else
numbers[x[1]] = numbers[x[0]];
numbers[x[0]] = 0;
} else
Console.WriteLine(sum(numbers));
}
}
}
|
using System;
using System.Collections.Generic;
public class Program {
public static Int64 sum(Dictionary<String, Int64> nums) {
Int64 sum = 0;
foreach (KeyValuePair<String, Int64> item in nums) {
sum += item.Value * Convert.ToInt64(item.Key);
}
return sum;
}
public static void Main(String[] args) {
var numbers = new Dictionary<String, Int64>();
Int64 numberOfElements = Convert.ToInt64(Console.ReadLine());
Int64 prevSum = 0;
foreach (String x in Console.ReadLine().Split(' ')) {
if (numbers.ContainsKey(x)) {
numbers[x] += 1;
} else {
numbers.Add(x, 1);
}
prevSum += Convert.ToInt64(x);
}
Int64 numOfOperations = Convert.ToInt64(Console.ReadLine());
for (Int64 i = 0; i < numOfOperations; ++i) {
String[] x = Console.ReadLine().Split(' ');
if (numbers.ContainsKey(x[0])) {
prevSum +=
((Convert.ToInt64(x[1]) - Convert.ToInt64(x[0])) * numbers[x[0]]);
Console.WriteLine(prevSum);
if (numbers.ContainsKey(x[1]))
numbers[x[1]] += numbers[x[0]];
else
numbers[x[1]] = numbers[x[0]];
numbers[x[0]] = 0;
} else
Console.WriteLine(prevSum);
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 210, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 210, 8, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 16, 12, 213, 63, 22], ["-", 0, 28, 0, 16, 12, 213, 3, 4, 0, 24], ["-", 0, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 213, 63, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 324
| 34
|
using System;
class c {
static void Main() {
int n = int.Parse(Console.ReadLine());
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int q = int.Parse(Console.ReadLine());
var x = new int[100001];
for (int i = 0; i < n; i++) {
x[a[i]]++;
}
long ans = 0;
for (int i = 0; i < 100001; i++) {
ans += i * x[i];
}
Console.WriteLine(ans);
for (int i = 0; i < q; i++) {
var bc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int b = bc[0], c = bc[1];
ans += (c - b) * x[b];
Console.WriteLine(ans);
x[c] += x[b];
x[b] = 0;
}
}
}
|
using System;
class c {
static void Main() {
int n = int.Parse(Console.ReadLine());
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int q = int.Parse(Console.ReadLine());
var x = new long[100001];
for (int i = 0; i < n; i++)
x[a[i]]++;
long ans = 0;
for (int i = 0; i < 100001; i++)
ans += i * x[i];
for (int i = 0; i < q; i++) {
var bc = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
long b = bc[0], c = bc[1];
ans += (c - b) * x[b];
Console.WriteLine(ans);
x[c] += x[b];
x[b] = 0;
}
}
}
|
[["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 225
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
hoge();
// System.Console.ReadLine();
}
public static void hoge() {
var n = long.Parse(System.Console.ReadLine());
var a = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var vlst = new Dictionary<long, long>();
foreach (var v in a) {
if (vlst.ContainsKey(v)) {
vlst[v]++;
} else {
vlst.Add(v, 1);
}
}
var q = long.Parse(System.Console.ReadLine());
var sum = a.Sum();
var query = a.AsEnumerable();
Dictionary<long, long> dic = new Dictionary<long, long>();
for (long i = 0; i < q; i++) {
var var =
System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var b = var[0];
var c = var[1];
var sa = c - b;
sa *= vlst[b];
sum += sa;
Console.WriteLine(sum);
if (!vlst.ContainsKey(c)) {
vlst.Add(c, 0);
}
vlst[c] += vlst[b];
vlst[b] = 0;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
hoge();
// System.Console.ReadLine();
}
public static void hoge() {
var n = long.Parse(System.Console.ReadLine());
var a = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var vlst = new Dictionary<long, long>();
foreach (var v in a) {
if (vlst.ContainsKey(v)) {
vlst[v]++;
} else {
vlst.Add(v, 1);
}
}
var q = long.Parse(System.Console.ReadLine());
var sum = a.Sum();
var query = a.AsEnumerable();
Dictionary<long, long> dic = new Dictionary<long, long>();
for (long i = 0; i < q; i++) {
var var =
System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var b = var[0];
var c = var[1];
if (!vlst.ContainsKey(b)) {
vlst.Add(b, 0);
}
var sa = c - b;
sa *= vlst[b];
sum += sa;
Console.WriteLine(sum);
if (!vlst.ContainsKey(c)) {
vlst.Add(c, 0);
}
vlst[c] += vlst[b];
vlst[b] = 0;
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 24], ["+", 15, 241, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 313
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var solver = new Solver(sw);
// var t = new Thread(solver.solve, 1 << 26); // 64 MB
// t.Start();
// t.Join();
solver.solve();
sw.Flush();
}
}
class Solver {
StreamWriter sw;
Scan sc;
void Prt(string a) => sw.WriteLine(a);
void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
void Prt(params object[] a) => Prt(string.Join(" ", a));
public Solver(StreamWriter sw) {
this.sw = sw;
this.sc = new Scan();
}
public void solve() {
int n = sc.Int;
var a = sc.IntArr;
var cnt = new int[100010];
long sum = 0;
foreach (var item in a) {
++cnt[item];
sum += item;
}
int q = sc.Int;
for (int i = 0; i < q; i++) {
int b, c;
sc.Multi(out b, out c);
sum += cnt[b] * (long)(c - b);
cnt[c] += cnt[b];
Prt(sum);
}
}
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
}
static class util {
public static readonly int M = 1000000007;
// public static readonly int M = 998244353;
public static readonly long LM = 1L << 60;
public static readonly double eps = 1e-11;
public static void DBG(string a) => Console.Error.WriteLine(a);
public static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
public static void DBG(params object[] a) => DBG(string.Join(" ", a));
public static void Assert(params bool[] conds) {
if (conds.Any(x => !x))
throw new Exception();
}
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static int CompareList<T>(IList<T> a, IList<T> b)
where T : IComparable<T> {
for (int i = 0; i < a.Count && i < b.Count; i++)
if (a[i].CompareTo(b[i]) != 0)
return a[i].CompareTo(b[i]);
return a.Count.CompareTo(b.Count);
}
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
static readonly int[] dd = { 0, 1, 0, -1 };
// static readonly string dstring = "RDLU";
public static P[] adjacents(int i,
int j) => Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k],
j + dd[k ^ 1]))
.ToArray();
public static P[] adjacents(int i, int j, int h, int w) =>
Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k], j + dd[k ^ 1]))
.Where(p => inside(p.v1, p.v2, h, w))
.ToArray();
public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2,
h, w);
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static T[] inv<T>(this Dictionary<T, int> dic) {
var res = new T[dic.Count];
foreach (var item in dic)
res[item.Value] = item.Key;
return res;
}
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
public static void Deconstruct<T>(this IList<T> v, out T a) { a = v[0]; }
public static void Deconstruct<T>(this IList<T> v, out T a, out T b) {
a = v[0];
b = v[1];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b,
out T c) {
a = v[0];
b = v[1];
c = v[2];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d, out T e) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
e = v[4];
}
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Threading;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var solver = new Solver(sw);
// var t = new Thread(solver.solve, 1 << 26); // 64 MB
// t.Start();
// t.Join();
solver.solve();
sw.Flush();
}
}
class Solver {
StreamWriter sw;
Scan sc;
void Prt(string a) => sw.WriteLine(a);
void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
void Prt(params object[] a) => Prt(string.Join(" ", a));
public Solver(StreamWriter sw) {
this.sw = sw;
this.sc = new Scan();
}
public void solve() {
int n = sc.Int;
var a = sc.IntArr;
var cnt = new int[100010];
long sum = 0;
foreach (var item in a) {
++cnt[item];
sum += item;
}
int q = sc.Int;
for (int i = 0; i < q; i++) {
int b, c;
sc.Multi(out b, out c);
sum += cnt[b] * (long)(c - b);
cnt[c] += cnt[b];
cnt[b] = 0;
Prt(sum);
}
}
}
class pair<T, U> : IComparable<pair<T, U>> {
public T v1;
public U v2;
public pair() : this(default(T), default(U)) {}
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) {
int c = Comparer<T>.Default.Compare(v1, a.v1);
return c != 0 ? c : Comparer<U>.Default.Compare(v2, a.v2);
}
public override string ToString() => v1 + " " + v2;
public void Deconstruct(out T a, out U b) {
a = v1;
b = v2;
}
}
static class util {
public static readonly int M = 1000000007;
// public static readonly int M = 998244353;
public static readonly long LM = 1L << 60;
public static readonly double eps = 1e-11;
public static void DBG(string a) => Console.Error.WriteLine(a);
public static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
public static void DBG(params object[] a) => DBG(string.Join(" ", a));
public static void Assert(params bool[] conds) {
if (conds.Any(x => !x))
throw new Exception();
}
public static pair<T, U> make_pair<T, U>(T v1, U v2) => new pair<T, U>(v1,
v2);
public static int CompareList<T>(IList<T> a, IList<T> b)
where T : IComparable<T> {
for (int i = 0; i < a.Count && i < b.Count; i++)
if (a[i].CompareTo(b[i]) != 0)
return a[i].CompareTo(b[i]);
return a.Count.CompareTo(b.Count);
}
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h
&& j >= 0 && j < w;
static readonly int[] dd = { 0, 1, 0, -1 };
// static readonly string dstring = "RDLU";
public static P[] adjacents(int i,
int j) => Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k],
j + dd[k ^ 1]))
.ToArray();
public static P[] adjacents(int i, int j, int h, int w) =>
Enumerable.Range(0, dd.Length)
.Select(k => new P(i + dd[k], j + dd[k ^ 1]))
.Where(p => inside(p.v1, p.v2, h, w))
.ToArray();
public static P[] adjacents(this P p) => adjacents(p.v1, p.v2);
public static P[] adjacents(this P p, int h, int w) => adjacents(p.v1, p.v2,
h, w);
public static Dictionary<T, int>
compress<T>(this IEnumerable<T> a) => a.Distinct()
.OrderBy(v => v)
.Select((v, i) => new { v, i })
.ToDictionary(p => p.v, p => p.i);
public static Dictionary<T, int> compress<T>(params IEnumerable<T>[] a) =>
compress(a.Aggregate(Enumerable.Union));
public static T[] inv<T>(this Dictionary<T, int> dic) {
var res = new T[dic.Count];
foreach (var item in dic)
res[item.Value] = item.Key;
return res;
}
public static void swap<T>(ref T a, ref T b)
where T : struct {
var t = a;
a = b;
b = t;
}
public static void swap<T>(this IList<T> a, int i, int j)
where T : struct {
var t = a[i];
a[i] = a[j];
a[j] = t;
}
public static T[] copy<T>(this IList<T> a) {
var ret = new T[a.Count];
for (int i = 0; i < a.Count; i++)
ret[i] = a[i];
return ret;
}
public static void Deconstruct<T>(this IList<T> v, out T a) { a = v[0]; }
public static void Deconstruct<T>(this IList<T> v, out T a, out T b) {
a = v[0];
b = v[1];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b,
out T c) {
a = v[0];
b = v[1];
c = v[2];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
}
public static void Deconstruct<T>(this IList<T> v, out T a, out T b, out T c,
out T d, out T e) {
a = v[0];
b = v[1];
c = v[2];
d = v[3];
e = v[4];
}
}
class Scan {
StreamReader sr;
public Scan() { sr = new StreamReader(Console.OpenStandardInput()); }
public Scan(string path) { sr = new StreamReader(path); }
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => sr.ReadLine().Trim();
public pair<T, U> Pair<T, U>() {
T a;
U b;
Multi(out a, out b);
return new pair<T, U>(a, b);
}
public P P => Pair<int, int>();
public int[] IntArr => StrArr.Select(int.Parse).ToArray();
public long[] LongArr => StrArr.Select(long.Parse).ToArray();
public double[] DoubleArr => StrArr.Select(double.Parse).ToArray();
public string[] StrArr =>
Str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public void Multi<T>(out T a) => a = cv<T>(Str);
public void Multi<T, U>(out T a, out U b) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
public void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
public void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
public void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = StrArr;
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
|
[["+", 8, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 2,282
| 7
|
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Extensions;
using DSA;
using static System.Math;
using static Extensions.MathExtension;
using static Extensions.ConsoleInputExtension;
using static Extensions.ConsoleOutputExtension;
class Solver {
public void Solve() {
// Solve Code Here
int n = Cin;
var dictionary = Enumerable.Range(0, n)
.Select(_ => ((long)Cin))
.GroupBy(val => val)
.ToDictionary(val => val.Key, val => val.Count());
var sum = dictionary.Select(pair => pair.Key * (long)pair.Value).Sum();
int q = Cin;
for (int i = 0; i < q; i++) {
int b = Cin, c = Cin;
if (!dictionary.ContainsKey(b)) {
Coutln(sum);
continue;
}
sum += (c - b) * dictionary[b];
if (dictionary.ContainsKey(c)) {
dictionary[c] += dictionary[b];
dictionary.Remove(b);
} else {
dictionary[c] = dictionary[b];
}
Coutln(sum);
}
}
}
// Other Classes Here
#if !DEBUG
class EntryPoint {
static void Main(string[] args) {
new Solver().Solve();
Flush();
}
}
#endif
namespace DSA {
public class PriorityQueue<T> {
private readonly List<Tuple<int, T>> _list = new List<Tuple<int, T>>();
public int Count => _list.Count;
public PriorityQueue() {}
public void Push(T item, int priority) {
_list.Add(Tuple.Create(priority, item));
int itemIndex = Count - 1, parentIndex;
while ((parentIndex = GetParentIndex(itemIndex)) != -1 &&
priority > _list[parentIndex].Item1) {
Swap(itemIndex, parentIndex);
itemIndex = parentIndex;
}
}
private int GetParentIndex(int index) {
if (index == 0)
return -1;
return ((index + 1) >> 1) - 1;
}
private Tuple<int, int> GetChildrenIndex(int index) {
var item2 = (index + 1) << 1;
var item1 = item2 - 1;
return Tuple.Create(item1, item2);
}
public T Pop() {
if (Count <= 0)
throw new IndexOutOfRangeException();
var item = _list[0].Item2;
_list[0] = _list[Count - 1];
_list.RemoveAt(Count - 1);
int index = 0;
Tuple<int, int> childrenIndex = GetChildrenIndex(index);
while (childrenIndex.Item1 < Count || childrenIndex.Item2 < Count) {
if (childrenIndex.Item2 >= Count ||
_list[childrenIndex.Item1].Item1 > _list[childrenIndex.Item2].Item1) {
if (_list[childrenIndex.Item1].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item1);
index = childrenIndex.Item1;
} else {
if (_list[childrenIndex.Item2].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item2);
index = childrenIndex.Item2;
}
childrenIndex = GetChildrenIndex(index);
}
return item;
}
public T Peek() { return _list[0].Item2; }
private void Swap(int index1, int index2) {
var tmp = _list[index1];
_list[index1] = _list[index2];
_list[index2] = tmp;
}
}
public class UnionFind {
private readonly int[] _array;
public UnionFind(int size) {
_array = new int[size];
for (int i = 0; i < size; i++) {
_array[i] = i;
}
}
public int GetRootNode(int n) {
if (_array[n] == n)
return n;
return _array[n] = GetRootNode(_array[n]);
}
public void UnionGroup(int a, int b) {
var rootA = GetRootNode(a);
var rootB = GetRootNode(b);
if (rootA == rootB)
return;
_array[rootA] = rootB;
}
public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b);
public bool IsRoot(int n) => _array[n] == n;
}
public delegate T SegTreeCombiner<T>(T item1, T item2);
public class SegTree<T> {
private readonly T _defaultItem;
private readonly SegTreeCombiner<T> _func;
private T[] List;
private int size;
public SegTree(T[] list, T defaultItem, SegTreeCombiner<T> func) {
_defaultItem = defaultItem;
_func = func;
size = 1;
while (size < list.Length)
size <<= 1;
List = new T[2 * size - 1];
for (int i = 0; i < list.Length; i++)
List[i + size - 1] = list[i];
for (int i = list.Length; i < size; i++)
List[i + size - 1] = defaultItem;
for (int i = size - 1 - 1; i >= 0; i--) {
List[i] = _func(List[2 * i + 1], List[2 * i + 2]);
}
}
public void Update(int index, T value) {
index += size - 1;
List[index] = value;
while (index > 0) {
index = (index - 1) >> 1;
List[index] = _func(List[2 * index + 1], List[2 * index + 2]);
}
}
public T Query(int a, int b) { return Query(a, b, 0, 0, size); }
private T Query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return _defaultItem;
if (a <= l && r <= b)
return List[k];
return _func(Query(a, b, k * 2 + 1, l, (l + r) >> 1),
Query(a, b, k * 2 + 2, (l + r) >> 1, r));
}
}
public static class BinarySearch {
public delegate bool Terms<T>(T i);
public static int UpperBound(int initLeft, int initRight, Terms<int> term) {
// TODO:範囲内に条件を満たす区間が存在しない場合に対応する
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static long UpperBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static int LowerBound(int initLeft, int initRight, Terms<int> term) {
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initRight && term(mid))
right = mid;
else
left = mid;
}
return right;
}
public static long LowerBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (term(mid))
right = mid;
else
left = mid;
}
return right;
}
}
}
struct ModInt {
public long Value { get; }
public static long Mod { get; set; } = 1000000000L + 7;
public ModInt(long l) {
long value = l % Mod;
while (value < 0)
value += Mod;
Value = value % Mod;
}
public static implicit operator long(ModInt m) { return m.Value; }
public static implicit operator ModInt(long l) { return new ModInt(l); }
public static ModInt operator +(ModInt a, ModInt b) {
return new ModInt(a.Value + b.Value);
}
public static ModInt operator -(ModInt a, ModInt b) {
return new ModInt(a.Value - b.Value);
}
public static ModInt operator *(ModInt a, ModInt b) {
return new ModInt(a.Value * b.Value);
}
public static ModInt operator /(ModInt a, ModInt b) {
return new ModInt(a * b.Inverse());
}
public override string ToString() { return Value.ToString(); }
}
static class ModIntMath {
public static ModInt Pow(this ModInt a, ModInt b) {
var pow = b.Value;
var m = a;
ModInt ans = new ModInt(1);
while (pow != 0) {
if ((pow & 1) == 1) {
ans *= m;
}
pow >>= 1;
m *= m;
}
return ans;
}
public static ModInt Inverse(this ModInt m) {
return m.Pow((ModInt)(ModInt.Mod - 2));
}
}
namespace Extensions {
public class ConsoleInputExtension {
private static readonly ConsoleInputExtension _cin =
new ConsoleInputExtension();
public static ConsoleInputExtension Cin => _cin;
private static readonly Queue<string> _inputQueue = new Queue<string>();
private ConsoleInputExtension() {}
public static implicit operator string(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return _inputQueue.Dequeue();
}
public static implicit operator int(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return int.Parse(_inputQueue.Dequeue());
}
public static implicit operator long(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return long.Parse(_inputQueue.Dequeue());
}
public static implicit operator float(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return float.Parse(_inputQueue.Dequeue());
}
public static implicit operator double(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return double.Parse(_inputQueue.Dequeue());
}
}
public static class ConsoleOutputExtension {
private static StringBuilder _builder = new StringBuilder();
public static void Cout(object o) { _builder.Append(o); }
public static void CoutF(object o) {
_builder.Append(o);
Flush();
}
public static void Coutln(object o) {
_builder.Append(o);
_builder.Append('\n');
}
public static void Coutln() { _builder.Append('\n'); }
public static void CoutlnF(object o) {
_builder.Append(o);
_builder.Append('\n');
Flush();
}
public static void Flush() {
Console.Write(_builder.ToString());
_builder.Clear();
}
}
public static class MathExtension {
//最小公倍数
public static int LCM(int num1, int num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
public static long LCM(long num1, long num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
//最大公約数
public static int GCD(int num1, int num2) {
int a = Math.Max(num1, num2);
int b = Math.Min(num1, num2);
if (b == 0)
return a;
int mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
public static long GCD(long num1, long num2) {
long a = Math.Max(num1, num2);
long b = Math.Min(num1, num2);
if (b == 0)
return a;
long mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
}
public static class EnumerableExtension {
public delegate void Function<in T>(T val);
public static void ForEach<T>(this IEnumerable<T> enumerable,
Function<T> function) {
foreach (var x in enumerable) {
function(x);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Extensions;
using DSA;
using static System.Math;
using static Extensions.MathExtension;
using static Extensions.ConsoleInputExtension;
using static Extensions.ConsoleOutputExtension;
class Solver {
public void Solve() {
// Solve Code Here
int n = Cin;
var dictionary = Enumerable.Range(0, n)
.Select(_ => ((long)Cin))
.GroupBy(val => val)
.ToDictionary(val => val.Key, val => val.Count());
var sum = dictionary.Select(pair => pair.Key * (long)pair.Value).Sum();
int q = Cin;
for (int i = 0; i < q; i++) {
int b = Cin, c = Cin;
if (!dictionary.ContainsKey(b)) {
Coutln(sum);
continue;
}
sum += (c - b) * dictionary[b];
if (dictionary.ContainsKey(c))
dictionary[c] += dictionary[b];
else
dictionary[c] = dictionary[b];
dictionary.Remove(b);
Coutln(sum);
}
}
}
// Other Classes Here
#if !DEBUG
class EntryPoint {
static void Main(string[] args) {
new Solver().Solve();
Flush();
}
}
#endif
namespace DSA {
public class PriorityQueue<T> {
private readonly List<Tuple<int, T>> _list = new List<Tuple<int, T>>();
public int Count => _list.Count;
public PriorityQueue() {}
public void Push(T item, int priority) {
_list.Add(Tuple.Create(priority, item));
int itemIndex = Count - 1, parentIndex;
while ((parentIndex = GetParentIndex(itemIndex)) != -1 &&
priority > _list[parentIndex].Item1) {
Swap(itemIndex, parentIndex);
itemIndex = parentIndex;
}
}
private int GetParentIndex(int index) {
if (index == 0)
return -1;
return ((index + 1) >> 1) - 1;
}
private Tuple<int, int> GetChildrenIndex(int index) {
var item2 = (index + 1) << 1;
var item1 = item2 - 1;
return Tuple.Create(item1, item2);
}
public T Pop() {
if (Count <= 0)
throw new IndexOutOfRangeException();
var item = _list[0].Item2;
_list[0] = _list[Count - 1];
_list.RemoveAt(Count - 1);
int index = 0;
Tuple<int, int> childrenIndex = GetChildrenIndex(index);
while (childrenIndex.Item1 < Count || childrenIndex.Item2 < Count) {
if (childrenIndex.Item2 >= Count ||
_list[childrenIndex.Item1].Item1 > _list[childrenIndex.Item2].Item1) {
if (_list[childrenIndex.Item1].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item1);
index = childrenIndex.Item1;
} else {
if (_list[childrenIndex.Item2].Item1 <= _list[index].Item1)
return item;
Swap(index, childrenIndex.Item2);
index = childrenIndex.Item2;
}
childrenIndex = GetChildrenIndex(index);
}
return item;
}
public T Peek() { return _list[0].Item2; }
private void Swap(int index1, int index2) {
var tmp = _list[index1];
_list[index1] = _list[index2];
_list[index2] = tmp;
}
}
public class UnionFind {
private readonly int[] _array;
public UnionFind(int size) {
_array = new int[size];
for (int i = 0; i < size; i++) {
_array[i] = i;
}
}
public int GetRootNode(int n) {
if (_array[n] == n)
return n;
return _array[n] = GetRootNode(_array[n]);
}
public void UnionGroup(int a, int b) {
var rootA = GetRootNode(a);
var rootB = GetRootNode(b);
if (rootA == rootB)
return;
_array[rootA] = rootB;
}
public bool IsSameGroup(int a, int b) => GetRootNode(a) == GetRootNode(b);
public bool IsRoot(int n) => _array[n] == n;
}
public delegate T SegTreeCombiner<T>(T item1, T item2);
public class SegTree<T> {
private readonly T _defaultItem;
private readonly SegTreeCombiner<T> _func;
private T[] List;
private int size;
public SegTree(T[] list, T defaultItem, SegTreeCombiner<T> func) {
_defaultItem = defaultItem;
_func = func;
size = 1;
while (size < list.Length)
size <<= 1;
List = new T[2 * size - 1];
for (int i = 0; i < list.Length; i++)
List[i + size - 1] = list[i];
for (int i = list.Length; i < size; i++)
List[i + size - 1] = defaultItem;
for (int i = size - 1 - 1; i >= 0; i--) {
List[i] = _func(List[2 * i + 1], List[2 * i + 2]);
}
}
public void Update(int index, T value) {
index += size - 1;
List[index] = value;
while (index > 0) {
index = (index - 1) >> 1;
List[index] = _func(List[2 * index + 1], List[2 * index + 2]);
}
}
public T Query(int a, int b) { return Query(a, b, 0, 0, size); }
private T Query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return _defaultItem;
if (a <= l && r <= b)
return List[k];
return _func(Query(a, b, k * 2 + 1, l, (l + r) >> 1),
Query(a, b, k * 2 + 2, (l + r) >> 1, r));
}
}
public static class BinarySearch {
public delegate bool Terms<T>(T i);
public static int UpperBound(int initLeft, int initRight, Terms<int> term) {
// TODO:範囲内に条件を満たす区間が存在しない場合に対応する
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static long UpperBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (mid != initLeft - 1 && term(mid))
left = mid;
else
right = mid;
}
return left;
}
public static int LowerBound(int initLeft, int initRight, Terms<int> term) {
int left = initLeft - 1, right = initRight;
while (right - left > 1) {
int mid = (left + right) >> 1;
if (mid != initRight && term(mid))
right = mid;
else
left = mid;
}
return right;
}
public static long LowerBound(long initLeft, long initRight,
Terms<long> term) {
long left = initLeft - 1, right = initRight;
while (right - left > 1) {
long mid = (left + right) >> 1;
if (term(mid))
right = mid;
else
left = mid;
}
return right;
}
}
}
struct ModInt {
public long Value { get; }
public static long Mod { get; set; } = 1000000000L + 7;
public ModInt(long l) {
long value = l % Mod;
while (value < 0)
value += Mod;
Value = value % Mod;
}
public static implicit operator long(ModInt m) { return m.Value; }
public static implicit operator ModInt(long l) { return new ModInt(l); }
public static ModInt operator +(ModInt a, ModInt b) {
return new ModInt(a.Value + b.Value);
}
public static ModInt operator -(ModInt a, ModInt b) {
return new ModInt(a.Value - b.Value);
}
public static ModInt operator *(ModInt a, ModInt b) {
return new ModInt(a.Value * b.Value);
}
public static ModInt operator /(ModInt a, ModInt b) {
return new ModInt(a * b.Inverse());
}
public override string ToString() { return Value.ToString(); }
}
static class ModIntMath {
public static ModInt Pow(this ModInt a, ModInt b) {
var pow = b.Value;
var m = a;
ModInt ans = new ModInt(1);
while (pow != 0) {
if ((pow & 1) == 1) {
ans *= m;
}
pow >>= 1;
m *= m;
}
return ans;
}
public static ModInt Inverse(this ModInt m) {
return m.Pow((ModInt)(ModInt.Mod - 2));
}
}
namespace Extensions {
public class ConsoleInputExtension {
private static readonly ConsoleInputExtension _cin =
new ConsoleInputExtension();
public static ConsoleInputExtension Cin => _cin;
private static readonly Queue<string> _inputQueue = new Queue<string>();
private ConsoleInputExtension() {}
public static implicit operator string(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return _inputQueue.Dequeue();
}
public static implicit operator int(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return int.Parse(_inputQueue.Dequeue());
}
public static implicit operator long(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return long.Parse(_inputQueue.Dequeue());
}
public static implicit operator float(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return float.Parse(_inputQueue.Dequeue());
}
public static implicit operator double(ConsoleInputExtension _) {
if (_inputQueue.Count == 0)
Console.ReadLine().Split(' ').ForEach(val => _inputQueue.Enqueue(val));
return double.Parse(_inputQueue.Dequeue());
}
}
public static class ConsoleOutputExtension {
private static StringBuilder _builder = new StringBuilder();
public static void Cout(object o) { _builder.Append(o); }
public static void CoutF(object o) {
_builder.Append(o);
Flush();
}
public static void Coutln(object o) {
_builder.Append(o);
_builder.Append('\n');
}
public static void Coutln() { _builder.Append('\n'); }
public static void CoutlnF(object o) {
_builder.Append(o);
_builder.Append('\n');
Flush();
}
public static void Flush() {
Console.Write(_builder.ToString());
_builder.Clear();
}
}
public static class MathExtension {
//最小公倍数
public static int LCM(int num1, int num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
public static long LCM(long num1, long num2) {
var gcd = GCD(num1, num2);
return num1 * (num2 / gcd);
}
//最大公約数
public static int GCD(int num1, int num2) {
int a = Math.Max(num1, num2);
int b = Math.Min(num1, num2);
if (b == 0)
return a;
int mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
public static long GCD(long num1, long num2) {
long a = Math.Max(num1, num2);
long b = Math.Min(num1, num2);
if (b == 0)
return a;
long mod;
while ((mod = a % b) != 0) {
a = b;
b = mod;
}
return b;
}
}
public static class EnumerableExtension {
public delegate void Function<in T>(T val);
public static void ForEach<T>(this IEnumerable<T> enumerable,
Function<T> function) {
foreach (var x in enumerable) {
function(x);
}
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 2,718
| 18
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
private static long mod = 1000000007;
static void Main(string[] args) {
var n = Read().Int();
var l = new long[n];
var r = ReadSplit();
var dic = new Dictionary<long, int>();
var al = new List<List<int>>();
for (int i = 0; i < n; i++) {
var a = r[i].Long();
var b = Convert.ToString(a, 2);
var nl = new List<int>();
var k = 0;
for (int j = b.Length - 1; j >= 0; j--) {
if (b[j] == '1') {
if (!dic.ContainsKey(k)) {
dic.Add(k, 1);
} else {
dic[k]++;
}
nl.Add(1);
} else {
nl.Add(0);
}
k++;
}
al.Add(nl);
}
var ansl = new long[n];
for (int i = 0; i < n; i++) {
var aa = al[i];
var ans = 0L;
var max = 0L;
if (dic.Any()) {
max = dic.Max(x => x.Key);
for (int j = 0; j <= max; j++) {
var ac = 0;
if (aa.Count - 1 < j) {
ac = 0;
} else {
ac = aa[j];
}
if ((dic[j] - ac) % 2 == 1) {
if (j == 0) {
ans += 1;
} else {
ans += (long)Math.Pow(2, j);
}
}
}
}
ansl[i] = ans;
}
var sb = new StringBuilder();
for (int i = 0; i < n; i++) {
sb.Append(ansl[i]);
sb.Append(" ");
}
WriteRead(sb.ToString());
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
private static bool ChangeMin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
private static bool ChangekMax<T>(ref T a, T b)
where T : IComparable {
if (b.CompareTo(a) > 0) {
a = b;
return true;
}
return false;
}
}
}
public static class Extentions {
public static int Int(this object obj) { return int.Parse(obj.ToString()); }
public static long Long(this object obj) {
return long.Parse(obj.ToString());
}
public static decimal Decimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double Double(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
public class Program {
private static long mod = 1000000007;
static void Main(string[] args) {
var n = Read().Int();
var l = new long[n];
var r = ReadSplit();
var dic = new Dictionary<long, int>();
var al = new List<List<int>>();
for (int i = 0; i < n; i++) {
var a = r[i].Long();
var b = Convert.ToString(a, 2);
var nl = new List<int>();
var k = 0;
for (int j = b.Length - 1; j >= 0; j--) {
if (b[j] == '1') {
if (!dic.ContainsKey(k)) {
dic.Add(k, 1);
} else {
dic[k]++;
}
nl.Add(1);
} else {
nl.Add(0);
}
k++;
}
al.Add(nl);
}
var ansl = new long[n];
for (int i = 0; i < n; i++) {
var aa = al[i];
var ans = 0L;
var max = 0L;
if (dic.Any()) {
max = dic.Max(x => x.Key);
for (int j = 0; j <= max; j++) {
var ac = 0;
if (aa.Count - 1 < j) {
ac = 0;
} else {
ac = aa[j];
}
var value = 0;
dic.TryGetValue(j, out value);
if ((value - ac) % 2 == 1) {
if (j == 0) {
ans += 1;
} else {
ans += (long)Math.Pow(2, j);
}
}
}
}
ansl[i] = ans;
}
var sb = new StringBuilder();
for (int i = 0; i < n; i++) {
sb.Append(ansl[i]);
sb.Append(" ");
}
WriteRead(sb.ToString());
}
public static string Read() { return Console.ReadLine(); }
public static string[] ReadSplit() { return Console.ReadLine().Split(' '); }
public static void WriteRead(object str) {
Console.WriteLine(str);
Read();
}
public static void Write(object str) { Console.WriteLine(str); }
private static bool ChangeMin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) > 0) {
a = b;
return true;
}
return false;
}
private static bool ChangekMax<T>(ref T a, T b)
where T : IComparable {
if (b.CompareTo(a) > 0) {
a = b;
return true;
}
return false;
}
}
}
public static class Extentions {
public static int Int(this object obj) { return int.Parse(obj.ToString()); }
public static long Long(this object obj) {
return long.Parse(obj.ToString());
}
public static decimal Decimal(this object obj) {
return decimal.Parse(obj.ToString());
}
public static double Double(this object obj) {
return double.Parse(obj.ToString());
}
public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key)
where T2 : struct {
T2 value;
if (d.TryGetValue(key, out value)) {
return value;
}
return new T2();
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 64, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 268], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 31, 16, 31, 23, 0, 16, 31, 204, 205, 22], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 70], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 31, 23, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 31, 22]]
| 8
| 794
| 20
|
using System;
class B {
public static void Main() {
string[] Ar = Console.ReadLine().Split(' ');
bool ans = false;
for (int i = int.Parse(Ar[0]); i >= 0; i--) {
for (int j = 0; j <= int.Parse(Ar[0]); j++) {
int TuAsi = i * 2;
int KaAsi = j * 4;
int Ashi = TuAsi + KaAsi;
if (Ashi == int.Parse(Ar[1])) {
ans = true;
}
}
}
if (ans == true)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
using System;
class B {
public static void Main() {
string[] Ar = Console.ReadLine().Split(' ');
bool ans = false;
for (int i = int.Parse(Ar[0]); i >= 0; i--) {
int j = int.Parse(Ar[0]) - i;
int TuAsi = i * 2;
int KaAsi = j * 4;
int Ashi = TuAsi + KaAsi;
if (Ashi == int.Parse(Ar[1])) {
ans = true;
}
}
if (ans == true)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 152
| 13
|
using System;
namespace aziz {
class Program {
static void Main(string[] args) {
String[] XY = Console.ReadLine().Split(' ');
int X = int.Parse(XY[0]);
int Y = int.Parse(XY[1]);
int legs;
string result = "No";
for (int i = 0; i <= X; i++) {
legs = 2 * i + (X - i) * 4;
if (legs == Y) {
result = "Yes";
return;
}
}
Console.WriteLine(result);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace aziz {
class Program {
static void Main(string[] args) {
String[] XY = Console.ReadLine().Split(' ');
int X = int.Parse(XY[0]);
int Y = int.Parse(XY[1]);
int legs;
string result = "No";
for (int i = 0; i <= X; i++) {
legs = 2 * i + (X - i) * 4;
if (legs == Y) {
result = "Yes";
break;
}
}
Console.WriteLine(result);
}
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["+", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["+", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["+", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94]]
| 8
| 129
| 14
|
using System;
using System.Globalization;
using System.IO;
using System.Text;
public class Program {
public static void Main(string[] args) {
var stdin = Console.OpenStandardInput();
var ss = new StreamScanner(stdin);
var p = new Program();
p.solve(ss);
stdin.Close();
}
private void solve(StreamScanner ss) {
var x = ss.Int;
var y = ss.Int;
var t = 0;
var k = 0;
for (t = 0; t <= x; ++t) {
for (k = 0; t + k <= x && calcLegs(t, k) <= y; ++k) {
if (calcLegs(t, k) == y) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
private int calcLegs(int tsuru, int kame) => 2 * tsuru + 4 * kame;
class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char {
get {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
}
public string Scan {
get {
var sb = new StringBuilder();
for (var b = Char; b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
}
public long Long {
get {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
}
public int Int => (int)Long;
public int[] IntArray(int n) {
var arr = new int[n];
for (var i = 0; i < n; ++i) {
arr[i] = Int;
}
return arr;
}
public double Double => double.Parse(Scan, CultureInfo.InvariantCulture);
}
}
|
using System;
using System.Globalization;
using System.IO;
using System.Text;
public class Program {
public static void Main(string[] args) {
var stdin = Console.OpenStandardInput();
var ss = new StreamScanner(stdin);
var p = new Program();
p.solve(ss);
stdin.Close();
}
private void solve(StreamScanner ss) {
var x = ss.Int;
var y = ss.Int;
for (var t = 0; t <= x; ++t) {
var k = x - t;
if (calcLegs(t, k) == y) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
private int calcLegs(int tsuru, int kame) => 2 * tsuru + 4 * kame;
class StreamScanner {
public StreamScanner(Stream stream) { str = stream; }
private readonly Stream str;
private readonly byte[] buf = new byte[1024];
private int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
private byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
public char Char {
get {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
}
public string Scan {
get {
var sb = new StringBuilder();
for (var b = Char; b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
}
public long Long {
get {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
}
public int Int => (int)Long;
public int[] IntArray(int n) {
var arr = new int[n];
for (var i = 0; i < n; ++i) {
arr[i] = Int;
}
return arr;
}
public double Double => double.Parse(Scan, CultureInfo.InvariantCulture);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 10, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 7, 8, 196, 0, 7, 10, 11, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 15, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 7, 15, 16, 31, 16, 31, 16, 17, 72], ["-", 0, 7, 15, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 98], ["-", 0, 7, 15, 16, 12, 16, 31, 213, 63, 22], ["-", 15, 16, 12, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["-", 15, 16, 12, 16, 31, 213, 3, 4, 0, 21], ["-", 12, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["-", 15, 16, 12, 16, 31, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 19], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 241, 0, 29], ["-", 0, 7, 8, 196, 0, 7, 26, 241, 0, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 603
| 34
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace atcoder {
class Program {
static void Main(string[] args) {
var xy =
Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
var x = xy[0];
var y = xy[1];
var result = x * 4;
for (var i = 0; i < x; i++) {
result -= 2;
if (result == y) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace atcoder {
class Program {
static void Main(string[] args) {
var xy =
Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
var x = xy[0];
var y = xy[1];
var result = x * 4;
if (result == y) {
Console.WriteLine("Yes");
return;
}
for (var i = 0; i < x; i++) {
result -= 2;
if (result == y) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["+", 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, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 142
| 19
|
using System;
namespace ABC170B {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine().Split(' ');
var x = int.Parse(str[0]);
var y = int.Parse(str[1]);
if (y % 2 != 0) {
Console.WriteLine("No");
}
var flag = false;
for (var i = 0; i <= x; i++) {
var tsuru = i * 4;
var kame = (x - i) * 2;
if (y == tsuru + kame) {
flag = true;
Console.WriteLine("Yes");
}
}
if (!flag) {
Console.WriteLine("No");
}
Console.ReadKey();
}
}
}
|
using System;
namespace ABC170B {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine().Split(' ');
var x = int.Parse(str[0]);
var y = int.Parse(str[1]);
var flag = false;
if (y % 2 == 0) {
for (var i = 0; i <= x; i++) {
var kame = i * 2;
var tsuru = (x - i) * 4;
if (y == tsuru + kame) {
flag = true;
Console.WriteLine("Yes");
break;
}
}
}
if (!flag) {
Console.WriteLine("No");
}
Console.ReadKey();
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 167
| 33
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Contest {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
var x = int.Parse(input[0]);
var y = int.Parse(input[1]);
for (int i = 0; i <= x; i++) {
for (int j = 0; j <= x - i; j++) {
if (i * 2 + j * 4 == y) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Contest {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
var x = int.Parse(input[0]);
var y = int.Parse(input[1]);
for (int i = 0; i <= x; i++) {
if (i * 2 + (x - i) * 4 == y) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 15, 16, 31, 16, 12, 16, 31, 23, 0, 24], ["+", 31, 16, 12, 16, 31, 23, 0, 16, 31, 22], ["+", 31, 16, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 31, 16, 12, 16, 31, 23, 0, 16, 12, 22], ["+", 15, 16, 31, 16, 12, 16, 31, 23, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 146
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionB {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var num_XY =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
var X = num_XY[0]; //頭数
var Y = num_XY[1]; //足数
//カメの数
var Kame = (Y - 2 * X) / 2;
//ツルの数
var Tsuru = (4 * X - Y) / 2;
if (Kame >= 0 && Tsuru >= 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionB {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var num_XY =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
var X = num_XY[0]; //頭数
var Y = num_XY[1]; //足数
if (Y % 2 == 0) //足数が偶数のときのみ判定
{
//カメの数
var Kame = (Y - 2 * X) / 2;
//ツルの数
var Tsuru = (4 * X - Y) / 2;
if (Kame >= 0 & Tsuru >= 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
} else
Console.WriteLine("No");
Console.Out.Flush();
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 67], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 75, 1, 0, 35]]
| 8
| 198
| 22
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp1 {
public class Class {
static void Main(string[] args) {
var XY = RL<int>();
for (var x = 0; x <= XY[0]; x++) {
for (var y = 0; y <= XY[0] - x; y++) {
if (x * 2 + y * 4 == XY[1]) {
Console.Write("Yes");
return;
}
}
}
Console.Write("No");
}
static T[] RL<T>()
where T : IComparable {
if (typeof(T) == typeof(int)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(int.Parse)
.ToArray();
}
if (typeof(T) == typeof(long)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(long.Parse)
.ToArray();
}
if (typeof(T) == typeof(double)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(double.Parse)
.ToArray();
}
if (typeof(T) == typeof(decimal)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(decimal.Parse)
.ToArray();
}
return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ConsoleApp1 {
public class Class {
static void Main(string[] args) {
var XY = RL<int>();
for (var x = 0; x <= XY[0]; x++) {
for (var y = 0; y <= XY[0] - x; y++) {
if (x * 2 + y * 4 == XY[1] && x + y == XY[0]) {
Console.Write("Yes");
return;
}
}
}
Console.Write("No");
}
static T[] RL<T>()
where T : IComparable {
if (typeof(T) == typeof(int)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(int.Parse)
.ToArray();
}
if (typeof(T) == typeof(long)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(long.Parse)
.ToArray();
}
if (typeof(T) == typeof(double)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(double.Parse)
.ToArray();
}
if (typeof(T) == typeof(decimal)) {
return (T[])(object)Console.ReadLine()
.Trim()
.Split()
.Select(decimal.Parse)
.ToArray();
}
return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
}
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 204, 205, 22], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 357
| 9
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace AtCoder.XXX.B {
public class Program {
public static void Main(string[] args) {
var datas = cr(); // 3 8
for (var i = 0; i < datas[0] + 1; i++) {
for (var j = 0; j < datas[0] + 1; j++) {
if ((i * 4) + (j * 2) == datas[1]) {
P("Yes");
return;
}
}
}
P("No");
}
private static StreamReader sr;
public static int[] Ecr() {
if (sr == null) {
sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
}
return sr.ReadLine().Split().Select(int.Parse).ToArray();
}
public static string Er() {
if (sr == null) {
sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
}
return sr.ReadLine();
}
public static string r() { return Console.ReadLine(); }
public static int[] cr() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
public static int cri() { return int.Parse(Console.ReadLine()); }
public static void P(string str) { Console.WriteLine(str); }
public static void P(int num) { P(num.ToString()); }
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace AtCoder.XXX.B {
public class Program {
public static void Main(string[] args) {
var datas = cr(); // 3 8
for (var i = 0; i < datas[0] + 1; i++) {
for (var j = 0; j < datas[0] + 1; j++) {
if ((i * 4) + (j * 2) == datas[1]) {
if (i + j == datas[0]) {
P("Yes");
return;
}
}
}
}
P("No");
}
private static StreamReader sr;
public static int[] Ecr() {
if (sr == null) {
sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
}
return sr.ReadLine().Split().Select(int.Parse).ToArray();
}
public static string Er() {
if (sr == null) {
sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
}
return sr.ReadLine();
}
public static string r() { return Console.ReadLine(); }
public static int[] cr() {
return Console.ReadLine().Split().Select(int.Parse).ToArray();
}
public static int cri() { return int.Parse(Console.ReadLine()); }
public static void P(string str) { Console.WriteLine(str); }
public static void P(int num) { P(num.ToString()); }
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 64, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 346
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionB {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
var x = inputLongArray[0];
var y = inputLongArray[1];
var ans = (y - (2 * x)) / 2m;
string result = "No";
if (ans >= 0 && ans <= x) {
result = "Yes";
}
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionB {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
var x = inputLongArray[0];
var y = inputLongArray[1];
var ans = (y - (2 * x)) / 2m;
string result = "No";
if (ans >= 0 && ans <= x && ans == (long)ans) {
result = "Yes";
}
Console.WriteLine(result);
Console.Out.Flush();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 74, 0, 24], ["+", 0, 57, 15, 16, 12, 16, 12, 74, 39, 199], ["+", 0, 57, 15, 16, 12, 16, 12, 74, 51, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 182
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace x {
class Program {
static void Main(string[] args) {
var (animalCount, legCount) = IOUtils.Read2Ints();
var tsuruCount = ((decimal)legCount - 4 * (decimal)animalCount) / (-2);
if (tsuruCount % 1 == 0 && tsuruCount >= 0) {
System.Console.WriteLine("Yes");
} else {
System.Console.WriteLine("No");
}
}
}
static class IOUtils {
public static (int a, int b) Read2Ints() {
var vals = ReadInts();
return (vals[0], vals[1]);
}
public static (int a, int b, int c) Read3Ints() {
var vals = ReadInts();
return (vals[0], vals[1], vals[2]);
}
public static IEnumerable<int[]> ReadIntLines(int count) {
for (int i = 0; i < count; i++) {
yield return ReadInts();
}
}
public static IEnumerable<long[]> ReadLongLines(int count) {
for (int i = 0; i < count; i++) {
yield return ReadLongs();
}
}
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static ulong ReadUlong() { return ulong.Parse(Console.ReadLine()); }
public static int[] ReadInts() {
return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
}
public static long[] ReadLongs() {
return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
}
public static void WriteNums(params int[] nums) {
Console.WriteLine(string.Join(" ", nums));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace x {
class Program {
static void Main(string[] args) {
var (animalCount, legCount) = IOUtils.Read2Ints();
// var tsuruCount = ((decimal)legCount - 4 * (decimal)animalCount) / (-2);
// if (tsuruCount % 1 == 0 && tsuruCount >= 0) {
// System.Console.WriteLine("Yes");
// } else {
// System.Console.WriteLine("No");
// }
var kame = (legCount - (2 * animalCount)) / (decimal)2;
if (kame % 1 == 0 && kame >= 0 && kame <= animalCount) {
System.Console.WriteLine("Yes");
} else {
System.Console.WriteLine("No");
}
}
}
static class IOUtils {
public static (int a, int b) Read2Ints() {
var vals = ReadInts();
return (vals[0], vals[1]);
}
public static (int a, int b, int c) Read3Ints() {
var vals = ReadInts();
return (vals[0], vals[1], vals[2]);
}
public static IEnumerable<int[]> ReadIntLines(int count) {
for (int i = 0; i < count; i++) {
yield return ReadInts();
}
}
public static IEnumerable<long[]> ReadLongLines(int count) {
for (int i = 0; i < count; i++) {
yield return ReadLongs();
}
}
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static long ReadLong() { return long.Parse(Console.ReadLine()); }
public static ulong ReadUlong() { return ulong.Parse(Console.ReadLine()); }
public static int[] ReadInts() {
return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
}
public static long[] ReadLongs() {
return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
}
public static void WriteNums(params int[] nums) {
Console.WriteLine(string.Join(" ", nums));
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 23, 0, 16, 31, 74, 39, 199], ["-", 0, 16, 31, 23, 0, 16, 31, 74, 0, 25], ["-", 0, 16, 31, 23, 0, 16, 12, 16, 31, 203], ["-", 0, 16, 31, 23, 0, 16, 12, 16, 17, 48], ["-", 31, 23, 0, 16, 12, 16, 12, 74, 39, 199], ["-", 31, 23, 0, 16, 12, 16, 12, 74, 0, 25], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 31, 203], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 48], ["+", 0, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["-", 0, 212, 0, 16, 12, 23, 0, 241, 0, 33], ["-", 0, 212, 0, 16, 12, 23, 0, 241, 0, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 51, 203], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 432
| 24
|
using System;
using System.Linq;
namespace Atcoder {
class Program {
public static void Main(string[] args) {
long[] input =
Console.ReadLine().Split(" ").Select(i => long.Parse(i)).ToArray();
if (4 * input[0] - input[1] >= 0 && ((4 * input[0] - input[1]) % 2) == 0)
Console.Write("Yes");
else
Console.Write("No");
}
}
}
|
using System;
using System.Linq;
namespace Atcoder {
class Program {
public static void Main(string[] args) {
long[] input =
Console.ReadLine().Split(" ").Select(i => long.Parse(i)).ToArray();
if (4 * input[0] - input[1] >= 0 && ((4 * input[0] - input[1]) % 2) == 0 &&
(4 * input[0] - input[1] <= 2 * input[0]))
Console.Write("Yes");
else
Console.Write("No");
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 31, 203], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 16, 31, 16, 12, 204, 205, 22], ["+", 31, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 15, 16, 12, 23, 0, 16, 31, 16, 17, 33], ["+", 12, 23, 0, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 17, 19], ["+", 15, 16, 12, 23, 0, 16, 12, 16, 31, 203], ["+", 15, 16, 12, 23, 0, 16, 12, 16, 17, 48], ["+", 12, 23, 0, 16, 12, 16, 12, 204, 205, 22], ["+", 0, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 117
| 21
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace ABC170 {
class B {
static void Main(string[] args) {
var XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
// var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
for (int i = 0; i <= XY[0]; i++) {
for (int j = 0; j <= XY[0] - i; j++) {
if (2 * i + 4 * j == XY[1]) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace ABC170 {
class B {
static void Main(string[] args) {
var XY = Console.ReadLine().Split().Select(long.Parse).ToArray();
// var CA = Enumerable.Repeat(0, (int)N).Select(_ =>
// Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
// var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();
for (int i = 0; i <= XY[0]; i++) {
for (int j = 0; j <= XY[0] - i; j++) {
if (i + j == XY[0] && 2 * i + 4 * j == XY[1]) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 16, 31, 16, 12, 204, 205, 22], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 143
| 9
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int BuildBitCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
int X;
int Y;
Multi(out X, out Y);
for (int i = 0; i <= X; i++) {
for (int j = 0; i + j <= X; j++) {
if (2 * i + 4 * j == Y) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace AtCoder {
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.OrdinalIgnoreCase);
return s.ToList();
}
public static void yesno(this bool b) { Console.WriteLine(b ? "yes" : "no"); }
public static void YesNo(this bool b) { Console.WriteLine(b ? "Yes" : "No"); }
public static void YESNO(this bool b) { Console.WriteLine(b ? "YES" : "NO"); }
public static int BuildBitCount(this int bits) {
bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
}
partial class AtCoder {
public string GetStr() { return Console.ReadLine().Trim(); }
public char GetChar() { return Console.ReadLine().Trim()[0]; }
public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
public double GetDouble() { return double.Parse(Console.ReadLine().Trim()); }
public string[] GetStrArray() { return Console.ReadLine().Trim().Split(' '); }
public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
Dictionary<int, List<int>> GetUnweightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<int>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<int>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
dic[a].Add(b);
if (isDirected == false)
dic[b].Add(a);
}
return dic;
}
Dictionary<int, List<Edge>> GetWeightedAdjacencyList(int N, int M,
bool isDirected,
bool isNode_0indexed) {
var dic = new Dictionary<int, List<Edge>>();
foreach (var e in Enumerable.Range(0, N)) {
dic.Add(e, new List<Edge>());
}
for (int i = 0; i < M; i++) {
var input = GetIntArray();
var a = isNode_0indexed ? input[0] : input[0] - 1;
var b = isNode_0indexed ? input[1] : input[1] - 1;
var c = input[2];
dic[a].Add(new Edge(b, c));
if (isDirected == false)
dic[b].Add(new Edge(a, c));
}
return dic;
}
bool eq<T, U>() => typeof(T).Equals(typeof(U));
T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
: eq<T, long>() ? ct<T, long>(long.Parse(s))
: eq<T, double>() ? ct<T, double>(double.Parse(s))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
void Multi<T>(out T a) => a = cv<T>(GetStr());
void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e,
out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
class Edge {
public Edge(int to, long length) {
To = to;
Length = length;
}
public int To { get; set; }
public long Length { get; set; }
}
partial class Program {
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new AtCoder().Solve();
Console.Out.Flush();
Console.Read();
}
}
public partial class AtCoder {
public void Solve() {
int X;
int Y;
Multi(out X, out Y);
for (int i = 0; i <= X; i++) {
if (2 * i + 4 * (X - i) == Y) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 24], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 17, 72], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 22], ["+", 15, 16, 31, 16, 12, 16, 12, 23, 0, 24], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["+", 15, 16, 31, 16, 12, 16, 12, 23, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,893
| 24
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class ProblemB {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var X = NN;
var Y = NN;
var max = X * 2;
var max2 = X * 4;
if (max <= Y && Y <= max2) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
public LIB_FastIODebug() {}
public override string Scan() => NextString();
public override long Long() => long.Parse(NextString());
public override double Double() => double.Parse(NextString());
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;
namespace Program {
public static class ProblemB {
static bool SAIKI = false;
static public int numberOfRandomCases = 0;
static public void MakeTestCase(List<string> _input, List<string> _output,
ref Func<string[], bool> _outputChecker) {}
static public void Solve() {
var X = NN;
var Y = NN;
var max = X * 2;
var max2 = X * 4;
if (max <= Y && Y <= max2) {
if (Y % 2 != 0) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
} else {
Console.WriteLine("No");
}
}
class Printer : StreamWriter {
public override IFormatProvider FormatProvider {
get { return CultureInfo.InvariantCulture; }
}
public Printer(Stream stream)
: base(stream, new UTF8Encoding(false, true)) {
base.AutoFlush = false;
}
public Printer(Stream stream, Encoding encoding) : base(stream, encoding) {
base.AutoFlush = false;
}
}
static LIB_FastIO fastio = new LIB_FastIODebug();
static public void Main(string[] args) {
if (args.Length == 0) {
fastio = new LIB_FastIO();
Console.SetOut(new Printer(Console.OpenStandardOutput()));
}
if (SAIKI) {
var t = new Thread(Solve, 134217728);
t.Start();
t.Join();
} else
Solve();
Console.Out.Flush();
}
static long NN => fastio.Long();
static double ND => fastio.Double();
static string NS => fastio.Scan();
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
static long Count<T>(this IEnumerable<T> x,
Func<T, bool> pred) => Enumerable.Count(x, pred);
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
static IOrderedEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) =>
Enumerable.OrderBy(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x,
Func<T1, T2> selector) =>
Enumerable.OrderBy(x.OrderByRand(), selector);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) =>
Enumerable.OrderByDescending(x.OrderByRand(), e => e);
static IOrderedEnumerable<T1>
OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) =>
Enumerable.OrderByDescending(x.OrderByRand(), selector);
static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) =>
x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<string>
OrderByDescending(this IEnumerable<string> x) =>
x.OrderByRand().OrderByDescending(e => e,
StringComparer.OrdinalIgnoreCase);
static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x,
Func<T, string> selector) =>
x.OrderByRand().OrderByDescending(selector,
StringComparer.OrdinalIgnoreCase);
static uint xorshift {
get {
_xsi.MoveNext();
return _xsi.Current;
}
}
static IEnumerator<uint> _xsi = _xsc();
static IEnumerator<uint> _xsc() {
uint x = 123456789, y = 362436069, z = 521288629,
w = (uint)(DateTime.Now.Ticks & 0xffffffff);
while (true) {
var t = x ^ (x << 11);
x = y;
y = z;
z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
yield return w;
}
}
}
}
namespace Library {
class LIB_FastIO {
public LIB_FastIO() { str = Console.OpenStandardInput(); }
readonly Stream str;
readonly byte[] buf = new byte[1024];
int len, ptr;
public bool isEof = false;
public bool IsEndOfStream {
get { return isEof; }
}
byte read() {
if (isEof)
throw new EndOfStreamException();
if (ptr >= len) {
ptr = 0;
if ((len = str.Read(buf, 0, 1024)) <= 0) {
isEof = true;
return 0;
}
}
return buf[ptr++];
}
char Char() {
byte b = 0;
do
b = read();
while (b < 33 || 126 < b);
return (char)b;
}
virtual public string Scan() {
var sb = new StringBuilder();
for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
sb.Append(b);
return sb.ToString();
}
virtual public long Long() {
long ret = 0;
byte b = 0;
var ng = false;
do
b = read();
while (b != '-' && (b < '0' || '9' < b));
if (b == '-') {
ng = true;
b = read();
}
for (; true; b = read()) {
if (b < '0' || '9' < b)
return ng ? -ret : ret;
else
ret = ret * 10 + b - '0';
}
}
virtual public double Double() {
return double.Parse(Scan(), CultureInfo.InvariantCulture);
}
}
class LIB_FastIODebug : LIB_FastIO {
Queue<string> param = new Queue<string>();
string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
public LIB_FastIODebug() {}
public override string Scan() => NextString();
public override long Long() => long.Parse(NextString());
public override double Double() => double.Parse(NextString());
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 1,460
| 22
|
using System;
using System.Linq;
namespace atcoder.abc170.c {
class Program {
static void Main(string[] args) {
int[] inputArray = getIntParams();
int X = inputArray[0];
int N = inputArray[1];
int ret = 0;
if (N == 0) {
ret = X;
} else {
int[] paramArray = getIntParams();
if (!paramArray.Contains(X)) {
ret = X;
} else {
for (int i = 1; i < 100; i++) {
if (X - i > 0 && !paramArray.Contains(X - i)) {
ret = X - i;
break;
}
if (X + i <= 100 && !paramArray.Contains(X + i)) {
ret = X + i;
break;
}
}
}
}
Console.WriteLine(ret);
}
//↓↓↓ shared function ↓↓↓
static int getIntParam() { return int.Parse(Console.ReadLine()); }
static int[] getIntParams() {
return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
}
static long getLongParam() { return long.Parse(Console.ReadLine()); }
static long[] getLongParams() {
return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
}
static string getStringParam() { return Console.ReadLine(); }
static string[] getStringParams() { return Console.ReadLine().Split(' '); }
}
}
|
using System;
using System.Linq;
namespace atcoder.abc170.c {
class Program {
static void Main(string[] args) {
int[] inputArray = getIntParams();
int X = inputArray[0];
int N = inputArray[1];
int ret = 0;
if (N == 0) {
ret = X;
} else {
int[] paramArray = getIntParams();
if (!paramArray.Contains(X)) {
ret = X;
} else {
for (int i = 1; i <= 100; i++) {
if (!paramArray.Contains(X - i)) {
ret = X - i;
break;
}
if (!paramArray.Contains(X + i)) {
ret = X + i;
break;
}
}
}
}
Console.WriteLine(ret);
}
//↓↓↓ shared function ↓↓↓
static int getIntParam() { return int.Parse(Console.ReadLine()); }
static int[] getIntParams() {
return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
}
static long getLongParam() { return long.Parse(Console.ReadLine()); }
static long[] getLongParams() {
return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
}
static string getStringParam() { return Console.ReadLine(); }
static string[] getStringParams() { return Console.ReadLine().Split(' '); }
}
}
|
[["-", 0, 57, 75, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 72], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 19]]
| 8
| 337
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int x = sc.NextInt();
int n = sc.NextInt();
int[] p = sc.IntArray();
var hs = new HashSet<int>();
foreach (var i in p) {
hs.Add(i);
}
for (int d = 0;; d++) {
if (!hs.Contains(x - d)) {
Console.WriteLine(x - d);
return;
}
if (!hs.Contains(x + d)) {
Console.WriteLine(x + d);
}
}
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int x = sc.NextInt();
int n = sc.NextInt();
int[] p = n == 0 ? new int[0] : sc.IntArray();
var hs = new HashSet<int>();
foreach (var i in p) {
hs.Add(i);
}
for (int d = 0;; d++) {
if (!hs.Contains(x - d)) {
Console.WriteLine(x - d);
return;
}
if (!hs.Contains(x + d)) {
Console.WriteLine(x + d);
return;
}
}
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 0, 200, 0, 212, 0, 41, 15, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 17, 60], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 101], ["+", 0, 200, 0, 212, 0, 41, 64, 227, 0, 228], ["+", 0, 212, 0, 41, 64, 227, 39, 224, 39, 199], ["+", 0, 41, 64, 227, 39, 224, 225, 226, 0, 70], ["+", 0, 41, 64, 227, 39, 224, 225, 226, 0, 203], ["+", 0, 41, 64, 227, 39, 224, 225, 226, 0, 73], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38]]
| 8
| 485
| 12
|
using System;
class Program {
static void Main(string[] args) {
string a = Console.ReadLine(); //標準入力
string[] aa = a.Split(' ');
int X = int.Parse(aa[0]);
int N = int.Parse(aa[1]);
string b = Console.ReadLine(); //標準入力
string[] bb = b.Split(' ');
int[] cc = new int[bb.Length];
for (int i = 0; i < cc.Length; i++) {
cc[i] = int.Parse(bb[i]);
}
int count = 101;
int bob = -2;
for (int i = -2; i < 101; i++) {
bool test = false;
for (int j = 0; j < cc.Length; j++) {
test = test || i == cc[j];
}
if (!test) {
int abs = (int)(Math.Abs(i - X));
if (count > abs) {
count = abs;
bob = i;
}
}
}
Console.WriteLine("{0}", bob);
}
static void changev(int h) {}
}
|
using System;
class Program {
static void Main(string[] args) {
string a = Console.ReadLine(); //標準入力
string[] aa = a.Split(' ');
int X = int.Parse(aa[0]);
int N = int.Parse(aa[1]);
if (N == 0) {
Console.WriteLine("{0}", X);
return;
}
string b = Console.ReadLine(); //標準入力
string[] bb = b.Split(' ');
int[] cc = new int[bb.Length];
for (int i = 0; i < cc.Length; i++) {
cc[i] = int.Parse(bb[i]);
}
int count = 101;
int bob = -2;
for (int i = -2; i < 102; i++) {
bool test = false;
for (int j = 0; j < cc.Length; j++) {
test = test || i == cc[j];
}
if (!test) {
int abs = (int)(Math.Abs(i - X));
if (count > abs) {
count = abs;
bob = i;
}
}
}
Console.WriteLine("{0}", bob);
}
static void changev(int h) {}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 261
| 23
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace AtCoder.ABC170 {
public class Problem3 {
public static void Main(string[] args) {
var a = Console.ReadLine().Split(" ");
var X = int.Parse(a[0]);
var N = int.Parse(a[1]);
if (N == 0) {
Console.WriteLine(X.ToString());
return;
}
if (N == 100) {
Console.WriteLine("0");
return;
}
var bs = Console.ReadLine().Split(" ");
var ps = new List<int>();
foreach (var b in bs) {
ps.Add(int.Parse(b));
}
var os = new List<int>();
for (var i = 0; i < 102; i++) {
if (!ps.Contains(i)) {
os.Add(i);
}
}
var diffs = new List<List<int>>();
foreach (var o in os.OrderBy(x => x)) {
var diff = Math.Abs(X - o);
var index = os.IndexOf(o);
var d = new List<int> { diff, index };
diffs.Add(d);
}
var idx = diffs.OrderBy(x => x[0]).ThenBy(x => x[1]).FirstOrDefault()[1];
var answer = os[idx];
Console.WriteLine(answer.ToString());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace AtCoder.ABC170 {
public class Problem3 {
public static void Main(string[] args) {
var a = Console.ReadLine().Split(" ");
var X = int.Parse(a[0]);
var N = int.Parse(a[1]);
if (N == 0) {
Console.WriteLine(X.ToString());
return;
}
if (N == 100) {
if (X <= 50) {
Console.WriteLine("0");
} else {
Console.WriteLine("101");
}
return;
}
var bs = Console.ReadLine().Split(" ");
var ps = new List<int>();
foreach (var b in bs) {
ps.Add(int.Parse(b));
}
var os = new List<int>();
for (var i = 0; i < 102; i++) {
if (!ps.Contains(i)) {
os.Add(i);
}
}
var diffs = new List<List<int>>();
foreach (var o in os.OrderBy(x => x)) {
var diff = Math.Abs(X - o);
var index = os.IndexOf(o);
var d = new List<int> { diff, index };
diffs.Add(d);
}
var idx = diffs.OrderBy(x => x[0]).ThenBy(x => x[1]).FirstOrDefault()[1];
var answer = os[idx];
Console.WriteLine(answer.ToString());
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 343
| 20
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Atcoder {
class Program {
public static void Main(string[] args) {
int[] input1 =
Console.ReadLine().Split(" ").Select(i => int.Parse(i)).ToArray();
int[] input2 = { 0 };
if (input1[1] != 0) {
input2 =
Console.ReadLine().Split(" ").Select(i => int.Parse(i)).ToArray();
} else
Console.Write(input1[0]);
var plusList = new List<long>();
var minusList = new List<long>();
foreach (var num in input2) {
var a = input1[0] - num;
if (a >= 0)
plusList.Add(a);
else {
minusList.Add(a);
}
};
plusList.Sort();
minusList.Sort();
minusList.Reverse();
int b = 0;
foreach (var num in plusList) {
if (num != b)
break;
b++;
}
var ansa = input1[0] - b;
int c = -1;
foreach (var num in minusList) {
if (num != c)
break;
c--;
}
var ansb = input1[0] - c;
if (Math.Abs(input1[0] - ansa) > Math.Abs(input1[0] - ansb))
Console.Write(ansb);
else
Console.Write(ansa);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Atcoder {
class Program {
public static void Main(string[] args) {
int[] input1 =
Console.ReadLine().Split(" ").Select(i => int.Parse(i)).ToArray();
int[] input2 = { 0 };
if (input1[1] != 0) {
input2 =
Console.ReadLine().Split(" ").Select(i => int.Parse(i)).ToArray();
var plusList = new List<long>();
var minusList = new List<long>();
foreach (var num in input2) {
var a = input1[0] - num;
if (a >= 0)
plusList.Add(a);
else {
minusList.Add(a);
}
};
plusList.Sort();
minusList.Sort();
minusList.Reverse();
int b = 0;
foreach (var num in plusList) {
if (num != b)
break;
b++;
}
var ansa = input1[0] - b;
int c = -1;
foreach (var num in minusList) {
if (num != c)
break;
c--;
}
var ansb = input1[0] - c;
if (Math.Abs(input1[0] - ansa) > Math.Abs(input1[0] - ansb))
Console.Write(ansb);
else
Console.Write(ansa);
} else
Console.Write(input1[0]);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["-", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["-", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["-", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 57, 75, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 75, 1, 0, 35], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 75, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 75, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 75, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
| 8
| 326
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var ary =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
var x = ary[0];
if (ary[1] == 0) {
Console.WriteLine(x);
return;
}
var ps =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long larger = 0;
for (var i = x; i < 102; i++) {
if (!ps.Contains(i)) {
larger = i;
break;
}
}
for (var i = x - 1; i >= -1; i--) {
if (!ps.Contains(i)) {
if (larger - x < x - i) {
Console.WriteLine(larger);
} else {
Console.WriteLine(i);
}
break;
}
}
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionC {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数配列の入力
var ary =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
var x = ary[0];
var ps = Console.ReadLine()
.Split(' ')
.Where(i => !string.IsNullOrEmpty(i))
.Select(i => long.Parse(i))
.ToArray();
long larger = 0;
for (var i = x; i < 102; i++) {
if (!ps.Contains(i)) {
larger = i;
break;
}
}
for (var i = x - 1; i >= -1; i--) {
if (!ps.Contains(i)) {
if (larger - x < x - i) {
Console.WriteLine(larger);
} else {
Console.WriteLine(i);
}
break;
}
}
Console.Out.Flush();
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 241, 0, 111], ["+", 0, 218, 8, 241, 0, 213, 63, 214, 205, 199], ["+", 0, 218, 8, 241, 0, 213, 63, 214, 0, 131], ["+", 0, 218, 8, 241, 0, 213, 63, 214, 141, 22], ["+", 0, 218, 8, 241, 0, 213, 3, 4, 0, 24], ["+", 8, 241, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 218, 8, 241, 0, 213, 3, 4, 0, 25]]
| 8
| 287
| 33
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var inputs =
Console.ReadLine().Split(' ').Select(txt => int.Parse(txt)).ToList();
var X = inputs[0];
var N = inputs[1];
HashSet<int> candidates = new HashSet<int>();
if (N == 0) {
candidates.Add(X);
} else {
var Ps =
Console.ReadLine().Split(' ').Select(txt => int.Parse(txt)).ToList();
var pmin = Ps.Min() - 1;
var pmax = Ps.Max() + 1;
for (int i = pmin; i <= pmax; i++) {
if (Ps.Contains(i))
continue;
candidates.Add(i);
}
if (X < pmin || pmax < X) {
candidates.Add(X);
}
}
var diff = X;
var ans = X;
foreach (var c in candidates.OrderBy(n => n).ToList()) {
var d = Math.Abs(c - X);
if (d < diff) {
diff = d;
ans = c;
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var inputs =
Console.ReadLine().Split(' ').Select(txt => int.Parse(txt)).ToList();
var X = inputs[0];
var N = inputs[1];
HashSet<int> candidates = new HashSet<int>();
if (N == 0) {
candidates.Add(X);
} else {
var Ps =
Console.ReadLine().Split(' ').Select(txt => int.Parse(txt)).ToList();
var pmin = Ps.Min() - 1;
var pmax = Ps.Max() + 1;
for (int i = pmin; i <= pmax; i++) {
if (Ps.Contains(i))
continue;
candidates.Add(i);
}
if (X < pmin || pmax < X) {
candidates.Add(X);
}
}
var diff = int.MaxValue;
var ans = int.MaxValue;
foreach (var c in candidates.OrderBy(n => n).ToList()) {
var d = Math.Abs(X - c);
if (d < diff) {
diff = d;
ans = c;
}
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 282
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder170 {
class ProgramC {
static void Main(string[] args) {
var input = Console.ReadLine();
var inputList = input.Split(" ");
int.TryParse(inputList[0], out var X);
int.TryParse(inputList[1], out var N);
if (N == 0) {
Console.WriteLine(X);
return;
}
var input2 = Console.ReadLine();
var inputList2 = input2.Split(" ").Select(int.Parse);
var abs = 1;
while (true) {
if (!inputList2.Any(d => d == X - abs)) {
Console.WriteLine(X - abs);
return;
}
if (!inputList2.Any(d => d == X + abs)) {
Console.WriteLine(X + abs);
return;
}
abs++;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder170 {
class ProgramC {
static void Main(string[] args) {
var input = Console.ReadLine();
var inputList = input.Split(" ");
int.TryParse(inputList[0], out var X);
int.TryParse(inputList[1], out var N);
if (N == 0) {
Console.WriteLine(X);
return;
}
var input2 = Console.ReadLine();
var inputList2 = input2.Split(" ").Select(int.Parse);
if (!inputList2.Any(d => d == X)) {
Console.WriteLine(X);
return;
}
var abs = 1;
while (true) {
if (!inputList2.Any(d => d == X - abs)) {
Console.WriteLine(X - abs);
return;
}
if (!inputList2.Any(d => d == X + abs)) {
Console.WriteLine(X + abs);
return;
}
abs++;
}
}
}
}
|
[["+", 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, 241, 0, 111], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 12, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 205
| 25
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace lean {
class Program {
static void Main() {
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x = a[0];
int[] lis = new int[] {};
if (a[1] == 0) {
Console.WriteLine(a[0]);
Environment.Exit(0);
}
lis = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] result = lis.Concat(new int[] { a[0] }).ToArray();
for (int i = 0; i <= 1919; i++) {
if (!result.Contains(a[0] - i)) {
Console.WriteLine(a[0] - i);
return;
}
if (!result.Contains(a[0] + i)) {
Console.WriteLine(a[0] + i);
return;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace lean {
class Program {
static void Main() {
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x = a[0];
int[] lis = new int[] {};
if (a[1] == 0) {
Console.WriteLine(a[0]);
Environment.Exit(0);
}
lis = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] result = lis;
for (int i = 0; i <= 1919; i++) {
if (!result.Contains(a[0] - i)) {
Console.WriteLine(a[0] - i);
return;
}
if (!result.Contains(a[0] + i)) {
Console.WriteLine(a[0] + i);
return;
}
}
}
}
}
|
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 205, 213, 3, 4, 0, 28, 0, 227, 0, 228], ["-", 3, 4, 0, 28, 0, 227, 39, 224, 39, 199], ["-", 0, 28, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 28, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 3, 4, 0, 28, 0, 227, 0, 229, 0, 45], ["-", 0, 28, 0, 227, 0, 229, 0, 204, 205, 22], ["-", 0, 227, 0, 229, 0, 204, 206, 207, 0, 70], ["-", 0, 229, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 227, 0, 229, 0, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 227, 0, 229, 0, 46], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 242
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
class Program {
public static void Main() {
var n = ReadLine().Split().Select(int.Parse).ToArray();
if (n[1] <= 1) {
WriteLine(n[0]);
return;
}
HashSet<int> list = new HashSet<int>();
for (int i = 1; i <= 100; i++) {
list.Add(i);
}
var m = ReadLine().Split().Select(int.Parse).ToArray();
for (int i = 1; i < m.Length; i++) {
list.Remove(m[i]);
}
if (!list.Contains(n[0])) {
WriteLine(n[0]);
return;
}
for (int i = 1; i < 100; i++) {
if (n[0] - i >= 1) {
if (list.Contains(n[0] - i)) {
WriteLine(n[0] - i);
return;
}
}
if (n[0] + i <= 100) {
if (list.Contains(n[0] + i)) {
WriteLine(n[0] + i);
return;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;
class Program {
public static void Main() {
var n = ReadLine().Split().Select(int.Parse).ToArray();
if (n[1] < 1) {
WriteLine(n[0]);
return;
}
HashSet<int> list = new HashSet<int>();
for (int i = -1; i <= 102; i++) {
list.Add(i);
}
var m = ReadLine().Split().Select(int.Parse).ToArray();
for (int i = 0; i < m.Length; i++) {
list.Remove(m[i]);
}
if (list.Contains(n[0])) {
WriteLine(n[0]);
return;
}
for (int i = 1; i <= 102; i++) {
if (n[0] - i >= -1) {
if (list.Contains(n[0] - i)) {
WriteLine(n[0] - i);
return;
}
}
if (n[0] + i <= 102) {
if (list.Contains(n[0] + i)) {
WriteLine(n[0] + i);
return;
}
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 10, 198, 0, 200, 0, 212, 0, 241, 0, 33], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 241, 0, 111], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 303
| 15
|
using System;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
var max = 10 * 10 * 10 * 10 * 10 * 10;
var count = new int[max];
for (int i = 0; i <= n; i++) {
count[arr[i]]++;
}
var isMultiples = Enumerable.Repeat(true, max + 1).ToArray();
foreach (var value in arr.Distinct()) {
for (int i = value * 2; i <= max; i += value)
isMultiples[i] = false;
}
var answer = 0;
for (int i = 0; i < n; i++) {
if (isMultiples[arr[i]] && count[arr[i]] == 1)
answer++;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
var max = arr.Max();
var count = new int[max + 1];
for (int i = 0; i < n; i++) {
count[arr[i]]++;
}
var isMultiples = Enumerable.Repeat(true, max + 1).ToArray();
foreach (var value in arr.Distinct()) {
for (int i = value * 2; i <= max; i += value)
isMultiples[i] = false;
}
var answer = 0;
for (int i = 0; i < n; i++) {
if (isMultiples[arr[i]] && count[arr[i]] == 1)
answer++;
}
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
[["-", 31, 16, 31, 16, 31, 16, 31, 16, 31, 203], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 48], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 212, 0, 16, 31, 16, 31, 16, 17, 48], ["-", 0, 212, 0, 16, 31, 16, 31, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 48], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 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], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["+", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18]]
| 8
| 254
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
class program {
static void Main() {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
bool[] table = new bool[1000001];
Array.Sort(a);
if (a[0] == 1) {
if (a[1] == 1) {
Console.Write(0);
return;
} else {
Console.Write(1);
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (!table[a[i]]) {
if (i + 1 < n) {
if (a[i] != a[i + 1])
ans++;
} else {
ans++;
}
for (int j = a[i]; j <= 1000000; j += a[i])
table[j] = true;
}
}
Console.Write(ans);
}
}
|
using System;
using System.Linq;
class program {
static void Main() {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
int amx = a.Max();
bool[] table = new bool[amx + 1];
Array.Sort(a);
if (a[0] == 1) {
if (n == 1) {
Console.Write(1);
return;
}
if (a[1] == 1) {
Console.Write(0);
return;
} else {
Console.Write(1);
return;
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (!table[a[i]]) {
if (i + 1 < n) {
if (a[i] != a[i + 1])
ans++;
} else {
ans++;
}
for (int j = a[i]; j <= amx; j += a[i])
table[j] = true;
}
}
Console.Write(ans);
}
}
|
[["-", 0, 208, 0, 231, 141, 232, 234, 232, 141, 22], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 0, 131], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 141, 22], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 35], ["-", 36, 36, 36, 36, 0, 208, 0, 231, 0, 233], ["-", 36, 36, 0, 208, 0, 231, 141, 232, 234, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 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, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 75, 196, 0, 37, 0, 38], ["+", 64, 196, 0, 57, 75, 196, 0, 37, 0, 35], ["-", 0, 57, 64, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 228
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
class program {
static void Main() {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
bool[] table = new bool[1000001];
Array.Sort(a);
if (a[0] == 1) {
if (a[1] == 1) {
Console.Write(0);
return;
} else {
Console.Write(1);
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (!table[a[i]]) {
if (i + 1 < n) {
if (a[i] != a[i + 1])
ans++;
} else {
ans++;
}
for (int j = a[i]; j <= 1000000; j += a[i])
table[j] = true;
}
}
Console.Write(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class program {
static void Main() {
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
bool[] table = new bool[1000001];
Array.Sort(a);
if (a[0] == 1) {
if (n == 1) {
Console.Write(1);
return;
}
if (a[1] == 1) {
Console.Write(0);
return;
} else {
Console.Write(1);
return;
}
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (!table[a[i]]) {
if (i + 1 < n) {
if (a[i] != a[i + 1])
ans++;
} else {
ans++;
}
for (int j = a[i]; j <= 1000000; j += a[i])
table[j] = true;
}
}
Console.Write(ans);
}
}
|
[["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 64, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 64, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 57, 75, 196, 0, 37, 0, 38]]
| 8
| 228
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
//入力を保持する
var N = int.Parse(Console.ReadLine());
var As = Console.ReadLine()
.Split()
.Select(e => int.Parse(e))
.OrderBy(e => e)
.ToArray();
// As配列内に1が1つ存在している場合は1以外は1によりすべて割り切れるため1が回答となる
if ((As.Count(e => e == 1) == 1)) {
Console.WriteLine("1");
}
// 1が1よりも多く存在している場合、1も1で割り切れるため0が回答となる
if ((As.Count(e => e == 1) > 1)) {
Console.WriteLine("0");
}
// As配列に含まれる数字の数をカウントするためNがとりうる最大の数分配列を準備する
var cnt = new int[100000];
for (var num = 0; num < N; num++) {
cnt[As[num]] = cnt[As[num]] + 1;
}
// Asに含まれる数字の倍数すべてをbool型で保持する
//-->割り切れないというのは言い換えればAiがその他の数の倍数にならないということ
var baisuFlgs = new bool[10001];
for (var num = 0; num < N; num++) {
var temp = As[num];
while (temp + As[num] <= 10000) {
temp = temp + As[num];
baisuFlgs[temp] = true;
}
}
// cnt配列内にAiの数が1であり、かつbaisuFlags配列内にAiの倍数のインデックスがFalseであればカントアップしていく
var ans = 0;
foreach (var i in As) {
if (baisuFlgs[i] == false && cnt[i] == 1) {
ans = ans + 1;
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
//入力を保持する
var N = int.Parse(Console.ReadLine());
var As = Console.ReadLine()
.Split()
.Select(e => int.Parse(e))
.OrderBy(e => e)
.ToArray();
// As配列内に1が1つ存在している場合は1以外は1によりすべて割り切れるため1が回答となる
if ((As.Count(e => e == 1) == 1)) {
Console.WriteLine("1");
return;
}
// 1が1よりも多く存在している場合、1も1で割り切れるため0が回答となる
if ((As.Count(e => e == 1) > 1)) {
Console.WriteLine("0");
return;
}
// As配列に含まれる数字の数をカウントするためNがとりうる最大の数分配列を準備する
var cnt = new int[1000001];
for (var num = 0; num < N; num++) {
cnt[As[num]] = cnt[As[num]] + 1;
}
// Asに含まれる数字の倍数すべてをbool型で保持する
//-->割り切れないというのは言い換えればAiがその他の数の倍数にならないということ
var baisuFlgs = new bool[1000001];
for (var num = 0; num < N; num++) {
var temp = As[num];
while (temp + As[num] <= 1000000) {
temp = temp + As[num];
baisuFlgs[temp] = true;
}
}
// cnt配列内にAiの数が1であり、かつbaisuFlags配列内にAiの倍数のインデックスがFalseであればカントアップしていく
var ans = 0;
foreach (var i in As) {
if (baisuFlgs[i] == false && cnt[i] == 1) {
ans = ans + 1;
}
}
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 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, 52, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 52, 15, 16, 12, 203]]
| 8
| 291
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
//入力を保持する
var N = int.Parse(Console.ReadLine());
var As = Console.ReadLine()
.Split()
.Select(e => int.Parse(e))
.OrderBy(e => e)
.ToArray();
// As配列内に1が1つ存在している場合は1以外は1によりすべて割り切れるため1が回答となる
// if ((As.Count(e => e == 1) == 1))
//{
// Console.WriteLine("1");
//}
////1が1よりも多く存在している場合、1も1で割り切れるため0が回答となる
// if ((As.Count(e => e == 1) > 1))
//{
// Console.WriteLine("0");
//}
// As配列に含まれる数字の数をカウントするためNがとりうる最大の数分配列を準備する
var cnt = new int[1000010];
for (var num = 0; num < N; num++) {
cnt[As[num]] = cnt[As[num]] + 1;
}
// Asに含まれる数字の倍数すべてをbool型で保持する
//-->割り切れないというのは言い換えればAiがその他の数の倍数にならないということ
var baisuFlgs = new bool[100001];
foreach (var i in As.Distinct()) {
var temp = i;
while (temp + i <= 100000) {
temp = temp + i;
baisuFlgs[temp] = true;
}
}
// cnt配列内にAiの数が1であり、かつbaisuFlags配列内にAiの倍数のインデックスがFalseであればカントアップしていく
var ans = 0;
for (var i = 0; i < N; i++) {
if (baisuFlgs[As[i]] == false && cnt[As[i]] == 1) {
ans = ans + 1;
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
//入力を保持する
var N = int.Parse(Console.ReadLine());
var As = Console.ReadLine()
.Split()
.Select(e => int.Parse(e))
.OrderBy(e => e)
.ToArray();
// As配列内に1が1つ存在している場合は1以外は1によりすべて割り切れるため1が回答となる
// if ((As.Count(e => e == 1) == 1))
//{
// Console.WriteLine("1");
//}
////1が1よりも多く存在している場合、1も1で割り切れるため0が回答となる
// if ((As.Count(e => e == 1) > 1))
//{
// Console.WriteLine("0");
//}
var max = (int)1e6;
// As配列に含まれる数字の数をカウントするためNがとりうる最大の数分配列を準備する
var cnt = new int[max + 10];
for (var num = 0; num < N; num++) {
cnt[As[num]]++;
}
// Asに含まれる数字の倍数すべてをbool型で保持する
//-->割り切れないというのは言い換えればAiがその他の数の倍数にならないということ
var baisuFlgs = new bool[max + 1];
foreach (var i in As.Distinct()) {
var temp = i;
while (temp + i <= max) {
temp += i;
baisuFlgs[temp] = true;
}
}
// cnt配列内にAiの数が1であり、かつbaisuFlags配列内にAiの倍数のインデックスがFalseであればカントアップしていく
var ans = 0;
for (var i = 0; i < N; i++) {
if (baisuFlgs[As[i]] == false && cnt[As[i]] == 1) {
ans++;
}
}
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 51, 250], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["+", 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], ["-", 8, 196, 0, 1, 0, 11, 31, 204, 205, 22], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["-", 31, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["-", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 206, 207, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29], ["-", 0, 210, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 210, 8, 196, 0, 52, 15, 16, 12, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 244
| 38
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder2 {
class Program {
static void Main(string[] args) {
var inputArray = retreiveLongArray();
var inputCount = 1;
// 不正な入力は処理しない
if (inputArray.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
long N = inputArray[0];
var AArray = retreiveLongArray();
var sortedArray = AArray.OrderBy(x => x).ToArray();
var sortedDictonary = new Dictionary<long, long>();
for (int i = 0; i < N; i++) {
sortedDictonary.Add(i, sortedArray[i]);
}
var max = sortedDictonary[N - 1];
var checkArray = new bool[max + 1];
for (int i = 0; i < max + 1; i++) {
checkArray[i] = true;
}
for (int i = 0; i < N; i++) {
var x = sortedDictonary[i];
if (!checkArray[x]) {
continue;
}
var wareru = x * 2;
while (wareru <= max) {
checkArray[wareru] = false;
wareru += x;
}
//同じ数がある場合の処理
var k = i + 1;
while (k < N && sortedDictonary[k] == x) {
checkArray[x] = false;
checkArray[k] = false;
k++;
}
}
//答えの出力
var ans = sortedDictonary.Where(x => checkArray[x.Value]).Count();
Console.WriteLine(ans);
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static long[] retreiveLongArray() {
var inputArray = Console.ReadLine().Split(' ');
var longArray = inputArray.Select(s => long.Parse(s));
return longArray.ToArray();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder2 {
class Program {
static void Main(string[] args) {
var inputArray = retreiveLongArray();
var inputCount = 1;
// 不正な入力は処理しない
if (inputArray.Length != inputCount) {
Console.WriteLine("invalid input");
return;
}
long N = inputArray[0];
var AArray = retreiveLongArray();
var sortedArray = AArray.OrderBy(x => x).ToArray();
var sortedDictonary = new Dictionary<long, long>();
for (int i = 0; i < N; i++) {
sortedDictonary.Add(i, sortedArray[i]);
}
var max = sortedDictonary[N - 1];
var checkArray = new bool[max + 1];
for (int i = 0; i < max + 1; i++) {
checkArray[i] = true;
}
for (int i = 0; i < N; i++) {
var x = sortedDictonary[i];
if (!checkArray[x]) {
continue;
}
var wareru = x * 2;
while (wareru <= max) {
checkArray[wareru] = false;
wareru += x;
}
//同じ数がある場合の処理
var k = i + 1;
while (k < N && sortedDictonary[k] == x) {
checkArray[x] = false;
checkArray[sortedDictonary[k]] = false;
k++;
}
}
//答えの出力
var ans = sortedDictonary.Where(x => checkArray[x.Value]);
// foreach (var a in ans) {
// Console.WriteLine(a.Value);
//}
Console.WriteLine(ans.Count());
}
/// <summary>
/// スペースで区切られた文字列配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static string[] retreiveStringArray() {
var inputArray = Console.ReadLine().Split(' ');
return inputArray;
}
/// <summary>
/// スペースで区切られた整数配列の入力を受け取る
/// </summary>
/// <returns></returns>
private static long[] retreiveLongArray() {
var inputArray = Console.ReadLine().Split(' ');
var longArray = inputArray.Select(s => long.Parse(s));
return longArray.ToArray();
}
}
}
|
[["+", 31, 204, 206, 207, 0, 28, 0, 204, 205, 22], ["+", 206, 207, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 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], ["+", 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
| 416
| 11
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC170D {
class Program {
static void Main(string[] args) {
var N = RInt;
var A = RInts.OrderBy(x => x).ToList();
int max = 1001010;
bool[] ok = new bool[max + 1];
int count = 0;
for (int i = 0; i < N; i++) {
if (!ok[A[i]]) {
if (i == N - 1 || A[i] != A[i + 1])
count++;
ok[A[i]] = true;
}
int sum = A[i] * 2;
while (sum <= max) {
if (ok[sum])
break;
ok[sum] = true;
sum += A[i];
}
}
Console.WriteLine(count);
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//以下未テスト
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC170D {
class Program {
static void Main(string[] args) {
var N = RInt;
var A = RInts.OrderBy(x => x).ToList();
int max = 1001010;
bool[] ok = new bool[max + 1];
int count = 0;
for (int i = 0; i < N; i++) {
if (!ok[A[i]]) {
if (i == N - 1 || A[i] != A[i + 1])
count++;
ok[A[i]] = true;
}
int sum = A[i];
if (i > 0 && A[i - 1] == A[i])
continue;
while (sum <= max) {
ok[sum] = true;
sum += A[i];
}
}
Console.WriteLine(count);
}
}
}
namespace Assistant {
static class Input {
static List<string> line = new List<string>();
static int index = 0;
static String RNext() {
if (line.Count <= index)
line.AddRange(Console.ReadLine().Split());
return line[index++];
}
public static int RInt => int.Parse(RNext());
public static long RLong => long.Parse(RNext());
public static int[] RInts =>
Console.ReadLine().Split().Select(int.Parse).ToArray();
public static long[] RLongs =>
Console.ReadLine().Split().Select(long.Parse).ToArray();
public static string RString => RNext();
//以下未テスト
public static int[] RIntsC(int c) =>
Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
public static long[] RLongsC(int c) =>
Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
public static char[][] RMap(int h) =>
Enumerable.Repeat(0, h)
.Select(x => Console.ReadLine().ToCharArray())
.ToArray();
}
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
static class Debug {
static public void Draw2D<T>(T[,] map, int mode = 1) {
#if DEBUG
int W = map.GetLength(0);
int H = map.GetLength(1);
string[,] map2 = new string[W + 1, H + 1];
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (i == 0 && j == 0)
map2[i, j] = 0.ToString();
else if (i == 0)
map2[i, j] = (j - 1).ToString();
else if (j == 0)
map2[i, j] = (i - 1).ToString();
else
map2[i, j] = map[i - 1, j - 1].ToString();
}
}
for (int i = 0; i < W + 1; i++) {
for (int j = 0; j < H + 1; j++) {
if (mode == 0)
Console.Write(map2[i, j].Last());
if (mode == 1)
Console.Write(map2[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
#endif
}
public static void Draw1D<T>(T[] array, int mode = 0) {
#if DEBUG
Console.WriteLine(string.Join(" ", array));
#endif
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 15, 16, 12, 16, 31, 204, 205, 22], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 204, 205, 22], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 117], ["+", 0, 7, 8, 196, 0, 57, 64, 116, 0, 35], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 24], ["-", 0, 52, 8, 196, 0, 57, 15, 204, 205, 22], ["-", 8, 196, 0, 57, 15, 204, 206, 207, 0, 70], ["-", 0, 57, 15, 204, 206, 207, 0, 28, 0, 22], ["-", 8, 196, 0, 57, 15, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 25], ["-", 0, 52, 8, 196, 0, 57, 64, 93, 0, 94], ["-", 0, 52, 8, 196, 0, 57, 64, 93, 0, 35]]
| 8
| 1,261
| 31
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
checked {
#if DEBUG
// TestCaseMaker.MakeTestCase1("../TextFile2.txt");
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../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 ary = ToIntArray(input.ReadLine(), n);
if (ary.Any(x => x == 1))
return 0;
int max = ary.Max();
var hash = new DefaultDectionary<long, int>(0);
foreach (var x in ary) {
hash[x] += 1;
}
var keys = hash.Keys.ToArray();
foreach (var v in keys) {
var x = hash[v];
if (x == 0)
continue;
if (hash[v] > 1) {
hash[v] = 0;
}
long y = v * 2;
long i = 3;
while (y <= max) {
if (hash.ContainsKey(y)) {
hash[y] = 0;
}
y = v * i;
i++;
}
}
long sum = 0;
foreach (var x in hash) {
sum += x.Value;
}
return sum;
}
class DefaultDectionary<Tkey, TValue> : Dictionary<Tkey, TValue> {
TValue DefaultValue;
public DefaultDectionary(TValue defaultvalue) {
this.DefaultValue = defaultvalue;
}
public new TValue this[Tkey key] {
get { if (this.ContainsKey(key)) return base[key];
else return DefaultValue;
}
set { base[key] = value; }
}
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
if (n == 0)
return ret;
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
checked {
#if DEBUG
// TestCaseMaker.MakeTestCase1("../TextFile2.txt");
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../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 ary = ToIntArray(input.ReadLine(), n);
int ones = ary.Count(x => x == 1);
if (ones > 0) {
if (ones > 1)
return 0;
return 1;
}
int max = ary.Max();
var hash = new DefaultDectionary<int, int>(0);
foreach (var x in ary) {
hash[x] += 1;
}
var keys = hash.Keys.ToArray();
foreach (var v in keys) {
var x = hash[v];
if (x == 0)
continue;
if (hash[v] > 1) {
hash[v] = 0;
}
var y = v * 2;
int i = 3;
while (y <= max) {
if (hash.ContainsKey(y)) {
hash[y] = 0;
}
y = v * i;
i++;
}
}
long sum = 0;
foreach (var x in hash) {
sum += x.Value;
}
return sum;
}
class DefaultDectionary<Tkey, TValue> : Dictionary<Tkey, TValue> {
TValue DefaultValue;
public DefaultDectionary(TValue defaultvalue) {
this.DefaultValue = defaultvalue;
}
public new TValue this[Tkey key] {
get { if (this.ContainsKey(key)) return base[key];
else return DefaultValue;
}
set { base[key] = value; }
}
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
if (n == 0)
return ret;
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
[["-", 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, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 8, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 57, 64, 37, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 210, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 210, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 503
| 30
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.