buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
string[] Inputline1 = Console.ReadLine().Split(' ');
string[] Inputline2 = Console.ReadLine().Split(' ');
int K = int.Parse(Inputline1[0]);
int N = int.Parse(Inputline1[1]);
var list = new List<int>();
for (int i = 0; i < N; i++) {
int num = int.Parse(Inputline2[i]);
list.Add(num);
}
int num2 = 0;
for (int i = 0; i < N - 1; i++) {
int s = list[i + 1] - list[i];
if (num2 < s) {
num2 = s;
}
}
if (list[0] != 0) {
int end = (K - list[N - 1]) + (list[0] - 0);
if (num2 < end) {
num2 = end;
}
}
Console.WriteLine(K - num2);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
string[] Inputline1 = Console.ReadLine().Split(' ');
string[] Inputline2 = Console.ReadLine().Split(' ');
int K = int.Parse(Inputline1[0]);
int N = int.Parse(Inputline1[1]);
var list = new List<int>();
for (int i = 0; i < N; i++) {
int num = int.Parse(Inputline2[i]);
list.Add(num);
}
int num2 = 0;
for (int i = 0; i < N - 1; i++) {
int s = list[i + 1] - list[i];
if (num2 < s) {
num2 = s;
}
}
int end = (K - list[N - 1]) + (list[0] - 0);
if (num2 < end) {
num2 = end;
}
Console.WriteLine(K - num2);
}
}
}
|
[["-", 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, 79], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 260
| 11
|
using System;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int k = int.Parse(input[0]);
int n = int.Parse(input[1]);
string[] aaray = Console.ReadLine().Split(' ');
int[] hikaku = new int[n];
int saichou = 0;
int saichoukukan = 0;
for (int i = 0; i < (n - 1); i++) {
int a = int.Parse(aaray[i]);
int b = int.Parse(aaray[i + 1]);
hikaku[i] = System.Math.Abs(b - a);
if (hikaku[i] > saichou) {
saichou = hikaku[i];
saichoukukan = i;
}
}
// 最初と最後の比較
int aa = int.Parse(aaray[0]);
if (aa == 0) {
aa = k;
}
int bb = int.Parse(aaray[n - 1]);
hikaku[n - 1] = System.Math.Abs(bb - aa);
if (hikaku[n - 1] > saichou) {
saichou = hikaku[n - 1];
saichoukukan = n - 1;
}
int kyori = 0;
for (int i = 0; i < n; i++) {
if (saichoukukan != i) {
kyori += hikaku[i];
}
}
Console.WriteLine(kyori);
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int k = int.Parse(input[0]);
int n = int.Parse(input[1]);
string[] aaray = Console.ReadLine().Split(' ');
int[] hikaku = new int[n];
int saichou = 0;
int saichoukukan = 0;
for (int i = 0; i < (n - 1); i++) {
int a = int.Parse(aaray[i]);
int b = int.Parse(aaray[i + 1]);
hikaku[i] = System.Math.Abs(b - a);
if (hikaku[i] > saichou) {
saichou = hikaku[i];
saichoukukan = i;
}
}
// 最初と最後の比較
int aa = int.Parse(aaray[0]);
int bb = int.Parse(aaray[n - 1]);
int cc = k - bb;
hikaku[n - 1] = aa + cc;
if (hikaku[n - 1] > saichou) {
saichou = hikaku[n - 1];
saichoukukan = n - 1;
}
int kyori = 0;
for (int i = 0; i < n; i++) {
if (saichoukukan != i) {
kyori += hikaku[i];
}
}
Console.WriteLine(kyori);
}
}
|
[["-", 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, 22], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 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, 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], ["-", 0, 11, 12, 213, 63, 214, 205, 214, 205, 22], ["-", 0, 11, 12, 213, 63, 214, 205, 214, 0, 131], ["-", 0, 11, 12, 213, 63, 214, 205, 214, 141, 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], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 317
| 30
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class C {
static StreamWriter Out =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
long K, N;
Input(out K, out N);
long[] A;
Inputs(out A);
long[] P = new long[N];
P[0] = K - A[N - 1];
for (long i = 1; i < N; i++) {
P[i] = A[i] - A[i - 1];
}
Array.Sort(P);
Array.Reverse(P);
Print(K - P[0]);
Out.Flush();
}
static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
static void Input<A>(out A a) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
}
static void Input<A, B>(out A a, out B b) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
}
static void Input<A, B, C>(out A a, out B b, out C c) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
}
static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
}
static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d,
out E e) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
}
static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d,
out E e, out F f) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
f = ChangeT<F>(words[5]);
}
static void Inputs<T>(out T[] array) {
array = Console.ReadLine()
.Split(new[] { ' ' },
options: StringSplitOptions.RemoveEmptyEntries)
.Select(s => ChangeT<T>(s))
.ToArray();
}
static void Print<T>(T s) => Out.WriteLine(s);
static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class C {
static StreamWriter Out =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
long K, N;
Input(out K, out N);
long[] A;
Inputs(out A);
Array.Sort(A);
long[] P = new long[N];
P[0] = K - A[N - 1] + A[0];
for (long i = 1; i < N; i++) {
P[i] = A[i] - A[i - 1];
}
Array.Sort(P);
Array.Reverse(P);
Print(K - P[0]);
Out.Flush();
}
static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
static void Input<A>(out A a) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
}
static void Input<A, B>(out A a, out B b) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
}
static void Input<A, B, C>(out A a, out B b, out C c) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
}
static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
}
static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d,
out E e) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
}
static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d,
out E e, out F f) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
f = ChangeT<F>(words[5]);
}
static void Inputs<T>(out T[] array) {
array = Console.ReadLine()
.Split(new[] { ' ' },
options: StringSplitOptions.RemoveEmptyEntries)
.Select(s => ChangeT<T>(s))
.ToArray();
}
static void Print<T>(T s) => Out.WriteLine(s);
static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}
|
[["+", 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], ["+", 12, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 1, 0, 11, 12, 16, 12, 204, 205, 22], ["+", 0, 11, 12, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 932
| 12
|
using System;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var KN = Console.ReadLine().Split(' ');
var K = int.Parse(KN[0]);
var N = int.Parse(KN[1]);
var distances =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long longdis = 0;
for (int i = 0; i < N; i++) {
var dis = Math.Abs(distances[i] - distances[(i + 1) % N]);
if (dis > longdis) {
longdis = dis;
}
}
var ret = K - longdis;
MyConsoleWrightLine(ret.ToString());
}
private static void MyConsoleWrightLine(string str) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Console.WriteLine(str);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
var KN = Console.ReadLine().Split(' ');
var K = int.Parse(KN[0]);
var N = int.Parse(KN[1]);
var distances =
Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
long longdis = 0;
for (int i = 0; i < N - 1; i++) {
var dis = Math.Abs(distances[i] - distances[i + 1]);
if (dis > longdis) {
longdis = dis;
}
}
var final = K - distances[N - 1] + distances[0];
if (final > longdis) {
longdis = final;
}
var ret = K - longdis;
MyConsoleWrightLine(ret.ToString());
}
private static void MyConsoleWrightLine(string str) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Console.WriteLine(str);
Console.Out.Flush();
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 206, 207, 0, 28, 0, 16, 31, 23, 0, 24], ["-", 206, 207, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 109], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 8, 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, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 33], ["+", 0, 212, 0, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 0, 16, 31, 16, 12, 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], ["+", 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, 22], ["+", 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, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 225
| 35
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
public class Program {
public static void Main() {
string[] input1 = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int K = int.Parse(input1[0]);
int N = int.Parse(input1[1]);
List<int> list = new List<int>();
for (int i = 0; i < N; i++) {
list.Add(int.Parse(input2[i]));
}
list.Sort();
int max = list[0] + (K - list[N - 1]);
for (int i = 0; i < N; i++) {
int temp = list[i + 1] - list[i];
if (temp > max) {
max = temp;
}
}
Console.WriteLine(K - max);
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
public class Program {
public static void Main() {
string[] input1 = Console.ReadLine().Split(' ');
string[] input2 = Console.ReadLine().Split(' ');
int K = int.Parse(input1[0]);
int N = int.Parse(input1[1]);
List<int> list = new List<int>();
for (int i = 0; i < N; i++) {
list.Add(int.Parse(input2[i]));
}
list.Sort();
int max = list[0] + (K - list[N - 1]);
for (int j = 0; j < N - 1; j++) {
int temp = list[j + 1] - list[j];
if (temp > max) {
max = temp;
}
}
Console.WriteLine(K - max);
}
}
|
[["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 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, 223, 0, 22], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 234
| 12
|
using System;
class ProgramC {
static void Main(string[] args) {
//入力
string[] s = Console.ReadLine().Split(' ');
long k = long.Parse(s[0]);
long n = long.Parse(s[1]);
string[] a = Console.ReadLine().Split(' ');
long ans = 10000000000;
for (long i = 0; i < n - 1; i++) {
long dis = k - (long.Parse(a[i + 1]) - long.Parse(a[i]));
ans = Math.Min(dis, ans);
}
long dis2 = long.Parse(a[n - 1]) - long.Parse(a[0]);
long temp2 = Math.Min(dis2, k - dis2);
ans = Math.Min(temp2, ans);
Console.WriteLine(ans);
}
}
|
using System;
class ProgramC {
static void Main(string[] args) {
//入力
string[] s = Console.ReadLine().Split(' ');
long k = long.Parse(s[0]);
long n = long.Parse(s[1]);
string[] a = Console.ReadLine().Split(' ');
long ans = 10000000000;
for (long i = 0; i < n - 1; i++) {
long dis = k - (long.Parse(a[i + 1]) - long.Parse(a[i]));
ans = Math.Min(dis, ans);
}
long dis2 = long.Parse(a[n - 1]) - long.Parse(a[0]);
ans = Math.Min(dis2, ans);
Console.WriteLine(ans);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 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, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 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, 12, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 201
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
int K, N;
sc.Make(out K, out N);
var A = sc.ArrInt;
var res = long.MaxValue;
for (int i = 0; i < N - 1; i++) {
chmin(ref res, K - Abs(A[(i + 1)] - A[i]));
}
WriteLine(Min(res, A[N - 1]));
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
int K, N;
sc.Make(out K, out N);
var A = sc.ArrInt;
var res = long.MaxValue;
for (int i = 0; i < N - 1; i++) {
chmin(ref res, K - Abs(A[(i + 1)] - A[i]));
}
WriteLine(Min(res, K - (A[0] + K - A[N - 1])));
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 0, 16, 12, 23, 0, 16, 12, 204, 205, 22], ["+", 12, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 1,641
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;
namespace AtCoder_1 {
class Program {
static void Main(string[] args) {
var KN = CinTAr();
var A = CinTAr();
// var f = new int[A.Length];
int max = 0;
long tot = 0;
for (int i = 1; i < A.Length; i++) {
var t = A[i] - A[i - 1];
max = Math.Max(max, t);
// f[i - 1] = t;
tot += t;
}
int q = KN[0] - A[A.Length - 1];
max = Math.Max(max, q);
// f[A.Length - 1] = q;
tot += q;
Cout(tot - max);
Cin();
}
static Random Rand = new Random();
static string[] AlphabetTable =
new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z" };
static int GetDigits(long num) {
return (int)Math.Floor(Math.Log10(num)) + 1;
}
static int GetNumByDigit(long num, int digit) {
return (int)((num / ((int)Math.Pow(10, digit - 1))) % 10);
}
static int loop(int num, int max) {
if (num > max) {
return num % max;
} else if (num < 0) {
return max - (-num) % max;
} else {
return num;
}
}
static long GCD(long a, long b) {
if (a < b) {
swap(ref a, ref b);
}
if (a % b == 0) {
return b;
} else {
return GCD(b, a % b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void swap<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static readonly int MOD10_9_7 = (1000000000 + 7);
static bool IsInt(double d) { return (int)d == d; }
static string Cin() { return ReadLine(); }
static string[] CinAr() { return ReadLine().Split(' '); }
static int CinT() { return S2i(Cin()); }
static int[] CinTAr() {
return CinAr().Select((x, i) => { return S2i(x); }).ToArray();
}
static long CinL() { return S2L(Cin()); }
static long[] CinLAr() {
return CinAr().Select((x, i) => { return S2L(x); }).ToArray();
}
static double CinD() { return S2D(Cin()); }
static double[] CinDAr() {
return CinAr().Select((x, i) => { return S2D(x); }).ToArray();
}
static int S2i(string s) { return int.Parse(s); }
static long S2L(string s) { return long.Parse(s); }
static double S2D(string s) { return double.Parse(s); }
static void Cout(object s) { WriteLine(s); }
static long[] yakusuu(long n) {
if (n == 1) {
return new long[] { 1 };
}
List<long> res = new List<long>();
res.Add(1);
for (long i = 2; i <= n / 2 + 1; i++) {
if (n % i == 0) {
res.Add(i);
}
}
res.Add(n);
return res.ToArray();
}
static bool isPrime(long num) {
if (num == 1) {
return false;
}
for (long i = 2; i <= Math.Sqrt(num) + 1; i++) {
if (num % i == 0) {
return false;
}
}
return true;
}
static void CoutAr<Type>(IEnumerable<Type> types) {
WriteLine(string.Join(" ", types));
}
public static long nCr(int n, int r) {
// naive: return Factorial(n) / (Factorial(r) * Factorial(n - r));
return nPr(n, r) / Factorial(r);
}
public static long nPr(int n, int r) {
// naive: return Factorial(n) / Factorial(n - r);
return FactorialDivision(n, n - r);
}
private static long FactorialDivision(int topFactorial,
int divisorFactorial) {
long result = 1;
for (int i = topFactorial; i > divisorFactorial; i--)
result *= i;
return result;
}
private static long Factorial(int i) {
if (i <= 1)
return 1;
return i * Factorial(i - 1);
}
}
public struct Pair<T> {
public T a;
public T b;
public T c;
public Pair(T _a, T _b) {
a = _a;
b = _b;
c = default(T);
}
public Pair(T _a, T _b, T _c) {
a = _a;
b = _b;
c = _c;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;
namespace AtCoder_1 {
class Program {
static void Main(string[] args) {
var KN = CinLAr();
var A = CinLAr();
long max = 0;
for (int i = 1; i < KN[1]; i++) {
long t = A[i] - A[i - 1];
max = Math.Max(max, t);
}
long q = KN[0] + A[0] - A[A.Length - 1];
max = Math.Max(max, q);
Cout(KN[0] - max);
Cin();
}
static Random Rand = new Random();
static string[] AlphabetTable =
new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R",
"S", "T", "U", "V", "W", "X", "Y", "Z" };
static int GetDigits(long num) {
return (int)Math.Floor(Math.Log10(num)) + 1;
}
static int GetNumByDigit(long num, int digit) {
return (int)((num / ((int)Math.Pow(10, digit - 1))) % 10);
}
static int loop(int num, int max) {
if (num > max) {
return num % max;
} else if (num < 0) {
return max - (-num) % max;
} else {
return num;
}
}
static long GCD(long a, long b) {
if (a < b) {
swap(ref a, ref b);
}
if (a % b == 0) {
return b;
} else {
return GCD(b, a % b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void swap<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static readonly int MOD10_9_7 = (1000000000 + 7);
static bool IsInt(double d) { return (int)d == d; }
static string Cin() { return ReadLine(); }
static string[] CinAr() { return ReadLine().Split(' '); }
static int CinT() { return S2i(Cin()); }
static int[] CinTAr() {
return CinAr().Select((x, i) => { return S2i(x); }).ToArray();
}
static long CinL() { return S2L(Cin()); }
static long[] CinLAr() {
return CinAr().Select((x, i) => { return S2L(x); }).ToArray();
}
static double CinD() { return S2D(Cin()); }
static double[] CinDAr() {
return CinAr().Select((x, i) => { return S2D(x); }).ToArray();
}
static int S2i(string s) { return int.Parse(s); }
static long S2L(string s) { return long.Parse(s); }
static double S2D(string s) { return double.Parse(s); }
static void Cout(object s) { WriteLine(s); }
static long[] yakusuu(long n) {
if (n == 1) {
return new long[] { 1 };
}
List<long> res = new List<long>();
res.Add(1);
for (long i = 2; i <= n / 2 + 1; i++) {
if (n % i == 0) {
res.Add(i);
}
}
res.Add(n);
return res.ToArray();
}
static bool isPrime(long num) {
if (num == 1) {
return false;
}
for (long i = 2; i <= Math.Sqrt(num) + 1; i++) {
if (num % i == 0) {
return false;
}
}
return true;
}
static void CoutAr<Type>(IEnumerable<Type> types) {
WriteLine(string.Join(" ", types));
}
public static long nCr(int n, int r) {
// naive: return Factorial(n) / (Factorial(r) * Factorial(n - r));
return nPr(n, r) / Factorial(r);
}
public static long nPr(int n, int r) {
// naive: return Factorial(n) / Factorial(n - r);
return FactorialDivision(n, n - r);
}
private static long FactorialDivision(int topFactorial,
int divisorFactorial) {
long result = 1;
for (int i = topFactorial; i > divisorFactorial; i--)
result *= i;
return result;
}
private static long Factorial(int i) {
if (i <= 1)
return 1;
return i * Factorial(i - 1);
}
}
public struct Pair<T> {
public T a;
public T b;
public T c;
public Pair(T _a, T _b) {
a = _a;
b = _b;
c = default(T);
}
public Pair(T _a, T _b, T _c) {
a = _a;
b = _b;
c = _c;
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 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, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 204, 205, 22], ["+", 0, 7, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 7, 15, 16, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 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, 107], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 72], ["+", 0, 212, 0, 16, 31, 16, 12, 204, 205, 22], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 70], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 31, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 204, 205, 22], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73]]
| 8
| 1,186
| 40
|
using System;
using static System.Console;
using static System.Math;
using System.Linq;
using System.Collections.Generic;
namespace Main {
class Program {
static void Main(string[] args) {
decimal[] tmp = ReadLine().Split(' ').Select(decimal.Parse).ToArray();
decimal N = tmp[0];
decimal K = tmp[1];
WriteLine(N % K);
}
}
}
|
using System;
using static System.Console;
using static System.Math;
using System.Linq;
using System.Collections.Generic;
namespace Main {
class Program {
static void Main(string[] args) {
decimal[] tmp = ReadLine().Split(' ').Select(decimal.Parse).ToArray();
decimal N = tmp[0];
decimal K = tmp[1];
N = N % K;
WriteLine(N > K - N ? K - N : N);
}
}
}
|
[["+", 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, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 17, 33], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 41, 64, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22]]
| 8
| 96
| 16
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var line1 =
Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToList();
var N = line1[0];
var K = line1[1];
var minN = N;
if (N > K) {
var x = (N / K) * K;
N -= x;
}
for (int i = 0; i < 100; i++) {
if (N > K) {
Console.WriteLine($"{i:0000} : N={N} K={K}");
N = N - K;
} else {
N = K - N;
}
if (N < minN) {
minN = N;
if (minN == 0)
break;
}
Console.WriteLine($" => N={N}");
}
Console.WriteLine(minN);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var line1 =
Console.ReadLine().Split(' ').Select(n => long.Parse(n)).ToList();
var N = line1[0];
var K = line1[1];
var minN = N;
if (N > K) {
var x = (N / K) * K;
N -= x;
}
for (int i = 0; i < 100; i++) {
if (N > K) {
// Console.WriteLine($"{i:0000} : N={N} K={K}");
N = N - K;
} else {
N = K - N;
}
if (N < minN) {
minN = N;
if (minN == 0)
break;
}
// Console.WriteLine($" => N={N}");
}
Console.WriteLine(minN);
}
}
|
[["-", 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, 283, 0, 295], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["-", 0, 28, 0, 283, 0, 284, 0, 298, 0, 102], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296], ["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 62], ["-", 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], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35]]
| 8
| 198
| 33
|
using System;
using System.Collections.Generic;
using System.Linq;
class Ho {
static void Main() {
var zennbu = Console.ReadLine().Split();
var N = long.Parse(zennbu[0]);
var K = long.Parse(zennbu[1]);
var j = 0;
if (K > N) {
Console.WriteLine(N);
} else if (N == K) {
Console.WriteLine(j);
} else {
long amari = N % K;
long saidai = (N - amari) / K;
long kotae1 = N - (saidai * K);
long kotae2 = -1 * (kotae1 - K);
if (kotae1 <= kotae2) {
Console.WriteLine(kotae1);
} else {
Console.WriteLine(kotae2);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Ho {
static void Main() {
var zennbu = Console.ReadLine().Split();
var N = long.Parse(zennbu[0]);
var K = long.Parse(zennbu[1]);
var j = 0;
if (K > N) {
long kotae1 = K - N;
if (kotae1 <= N) {
Console.WriteLine(kotae1);
} else {
Console.WriteLine(N);
}
} else if (N == K) {
Console.WriteLine(j);
} else {
long amari = N % K;
long saidai = (N - amari) / K;
long kotae1 = N - (saidai * K);
long kotae2 = -1 * (kotae1 - K);
if (kotae1 <= kotae2) {
Console.WriteLine(kotae1);
} else {
Console.WriteLine(kotae2);
}
}
}
}
|
[["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 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, 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, 19], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 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, 22], ["+", 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
| 170
| 25
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = long.Parse(Console.ReadLine());
decimal[] nk = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
var n = nk[0];
var k = nk[1];
decimal ans = 0;
if (n >= k && n % k == 0) {
ans = 0;
} else if (n < k && k % n == 0) {
ans = n;
} else {
ans = Math.Min(Math.Abs((n % k)), Math.Abs((n % k) - k));
}
// 出力
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = long.Parse(Console.ReadLine());
decimal[] nk = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
var n = nk[0];
var k = nk[1];
decimal ans = 0;
if (n == 0) {
ans = 0;
} else if (n >= k && n % k == 0) {
ans = 0;
} else if (n < k && k % n == 0) {
ans = n;
} else {
ans = Math.Min(Math.Abs((n % k)), Math.Abs((n % k) - k));
}
// 出力
Console.WriteLine(ans);
}
}
|
[["+", 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], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 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]]
| 8
| 169
| 13
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
namespace AtCoderWorkspace {
public class Solver {
public void Solve() {
var cin = new Scanner();
var n = cin.nextLong();
var k = cin.nextLong();
var ans = n;
ans = Math.Min(n % k, ans);
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public int[] DPArrayInt(int N, int ex) {
int[] Array = new int[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextInt();
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public long[] DPArrayLong(int N, int ex) {
long[] Array = new long[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextLong();
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] s) => new Solver().Solve();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
namespace AtCoderWorkspace {
public class Solver {
public void Solve() {
var cin = new Scanner();
var n = cin.nextLong();
var k = cin.nextLong();
var ans = n;
ans = Math.Min(n % k, ans);
ans = Math.Min(ans, Math.Abs(ans - k));
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public int[] DPArrayInt(int N, int ex) {
int[] Array = new int[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextInt();
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public long[] DPArrayLong(int N, int ex) {
long[] Array = new long[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextLong();
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] s) => new Solver().Solve();
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 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], ["+", 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, 12, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 582
| 18
|
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 nk = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var mod = nk[0] % nk[1];
if (nk[0] <= nk[1] || mod == 0) {
Console.WriteLine(mod);
return;
}
Console.WriteLine(Math.Abs(mod - nk[1]));
}
}
}
|
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 nk = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
var mod = nk[0] % nk[1];
Console.WriteLine(mod <= Math.Abs(mod - nk[1]) ? mod
: Math.Abs(mod - nk[1]));
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 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, 57, 15, 16, 31, 16, 31, 204, 205, 22], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 15, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["+", 0, 41, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 41, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 41, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 41, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 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, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 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, 41, 0, 101], ["-", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102]]
| 8
| 178
| 35
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
class program {
static public int mod = 1000000007;
static void Main() {
var k = rint();
long ans = 0;
var lunlun = new int[10];
var isdig = new bool[10];
var isdigup = 0;
for (int i = 0; i < k; i++) {
lunlun[0]++;
for (int j = 0; j < 9; j++) {
if ((lunlun[j] > lunlun[j + 1] + 1 && isdig[j + 1]) || lunlun[j] > 9) {
lunlun[j + 1]++;
isdig[j + 1] = true;
if (lunlun[j + 1] > 9)
lunlun[j] = 0;
else {
isdigup = j;
lunlun[j] = lunlun[j + 1] - 1;
}
}
}
if (isdigup != 0) {
for (int h = isdigup; h >= 0; h--) {
if (lunlun[h + 1] > 0)
lunlun[h] = lunlun[h + 1] - 1;
}
isdigup = 0;
}
}
long dig = 1;
for (int j = 0; j < 10; j++) {
ans += dig * lunlun[j];
dig *= 10;
}
Write(ans);
}
static int pow(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray2(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
static void WriteArray(int[] a, int b) {
for (int i = 0; i < b; i++) {
Write(" ");
Write(a[i]);
}
WriteLine();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
class program {
static public int mod = 1000000007;
static void Main() {
var k = rint();
long ans = 0;
var lunlun = new int[10];
var isdig = new bool[10];
var isdigup = 0;
for (int i = 0; i < k; i++) {
lunlun[0]++;
for (int j = 0; j < 9; j++) {
if ((lunlun[j] > lunlun[j + 1] + 1 && isdig[j + 1]) || lunlun[j] > 9) {
lunlun[j + 1]++;
isdig[j + 1] = true;
if (lunlun[j + 1] > 9)
lunlun[j] = 0;
else {
isdigup = j;
lunlun[j] = lunlun[j + 1] - 1;
}
}
}
if (isdigup != 0) {
for (int h = isdigup; h >= 0; h--) {
if (lunlun[h + 1] > 0)
lunlun[h] = lunlun[h + 1] - 1;
else
lunlun[h] = lunlun[h + 1];
}
isdigup = 0;
}
}
long dig = 1;
for (int j = 0; j < 10; j++) {
ans += dig * lunlun[j];
dig *= 10;
}
Write(ans);
}
static int pow(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray2(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
static void WriteArray(int[] a, int b) {
for (int i = 0; i < b; i++) {
Write(" ");
Write(a[i]);
}
WriteLine();
}
}
|
[["+", 64, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 57, 75, 1, 0, 11, 31, 204, 205, 22], ["+", 75, 1, 0, 11, 31, 204, 206, 207, 0, 70], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 75, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 1, 0, 11, 12, 204, 205, 22], ["+", 75, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 75, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 75, 1, 0, 35]]
| 8
| 971
| 13
|
using System;
using System.Text;
namespace ConsoleApp3 {
internal class Digit {
public Digit() {
Value = 0;
Left = new Digit(1, null, this);
}
private Digit(int value, Digit left, Digit right) {
Value = value;
Left = left;
Right = right;
}
public int Value { get; private set; }
public Digit Left { get; private set; }
public Digit Right { get; }
private static void Reset(Digit d) {
var piv = d;
while (piv.Right != null) {
if (piv.Value == 0)
piv.Right.Value = 0;
else
piv.Right.Value = piv.Value - 1;
piv = piv.Right;
}
}
public void Next() {
if (Left == null) {
Left = new Digit(1, null, this);
Reset(Left);
return;
}
var tmp = Value + 1;
if (Math.Abs(Left.Value - Value + 1) <= 1 && Value < 9) {
Value += 1;
Reset(this);
return;
}
if (Left.Left == null && Left.Value < 9) {
Left.Value += 1;
Reset(Left);
return;
}
Left.Next();
}
public override string ToString() {
if (Right != null)
throw new InvalidOperationException();
var bld = new StringBuilder();
var piv = this;
while (piv.Left != null)
piv = piv.Left;
while (piv != null) {
bld.Append(piv.Value);
piv = piv.Right;
}
return bld.ToString();
}
}
internal class Program {
private static void Main(string[] args) {
var k = int.Parse(Console.ReadLine());
if (k <= 10) {
Console.WriteLine(k);
} else {
var hoge = new Digit();
for (var i = 0; i < k - 10; i++)
hoge.Next();
Console.WriteLine(hoge);
}
}
}
}
|
using System;
using System.Text;
namespace ConsoleApp3 {
internal class Digit {
public Digit() {
Value = 0;
Left = new Digit(1, null, this);
}
private Digit(int value, Digit left, Digit right) {
if (value < 0 && value > 10)
throw new ArgumentOutOfRangeException(nameof(value));
Value = value;
Left = left;
Right = right;
}
public int Value { get; private set; }
public Digit Left { get; private set; }
public Digit Right { get; }
private static void Reset(Digit d) {
var piv = d;
while (piv.Right != null) {
if (piv.Value == 0)
piv.Right.Value = 0;
else
piv.Right.Value = piv.Value - 1;
piv = piv.Right;
}
}
public void Next() {
if (Left == null) {
Left = new Digit(1, null, this);
Reset(Left);
return;
}
var tmp = Value + 1;
if (Math.Abs(Left.Value - tmp) <= 1 && tmp < 10) {
Value = tmp;
Reset(this);
return;
}
if (Left.Left == null && Left.Value < 9) {
Left.Value += 1;
Reset(Left);
return;
}
Left.Next();
}
public override string ToString() {
if (Right != null)
throw new InvalidOperationException();
var bld = new StringBuilder();
var piv = this;
while (piv.Left != null)
piv = piv.Left;
while (piv != null) {
bld.Append(piv.Value);
piv = piv.Right;
}
return bld.ToString();
}
}
internal class Program {
private static void Main(string[] args) {
var k = int.Parse(Console.ReadLine());
if (k <= 10) {
Console.WriteLine(k);
} else {
var hoge = new Digit();
for (var i = 0; i < k - 10; i++)
hoge.Next();
Console.WriteLine(hoge);
}
}
}
}
|
[["+", 8, 201, 0, 263, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 263, 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, 18], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 263, 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, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 201, 0, 263, 8, 196, 0, 57, 0, 25], ["+", 0, 263, 8, 196, 0, 57, 64, 293, 0, 294], ["+", 8, 196, 0, 57, 64, 293, 0, 230, 0, 228], ["+", 8, 196, 0, 57, 64, 293, 0, 230, 39, 22], ["+", 0, 57, 64, 293, 0, 230, 3, 4, 0, 24], ["+", 0, 230, 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], ["+", 0, 57, 64, 293, 0, 230, 3, 4, 0, 25], ["+", 0, 263, 8, 196, 0, 57, 64, 293, 0, 35], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 425
| 32
|
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class ProgramD {
static void Main(string[] args) {
//入力
int k = int.Parse(Console.ReadLine());
var q = new Queue<int>();
for (int i = 0; i < 9; i++)
q.Enqueue(i + 1);
int temp = 0;
for (int i = 0; i < k; i++) {
temp = q.Dequeue();
if (temp % 10 == 0) {
q.Enqueue(temp * 10);
q.Enqueue(temp * 10 + 1);
} else if (temp % 10 == 9) {
q.Enqueue(temp * 10 + 8);
q.Enqueue(temp * 10 + 9);
} else {
q.Enqueue(temp * 10 + temp - 1);
q.Enqueue(temp * 10 + temp);
q.Enqueue(temp * 10 + temp + 1);
}
}
Console.WriteLine(temp);
}
}
|
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class ProgramD {
static void Main(string[] args) {
//入力
int k = int.Parse(Console.ReadLine());
var q = new Queue<long>();
for (int i = 0; i < 9; i++)
q.Enqueue(i + 1);
long temp = 0;
for (int i = 0; i < k; i++) {
temp = q.Dequeue();
if (temp % 10 == 0) {
q.Enqueue(temp * 10);
q.Enqueue(temp * 10 + 1);
} else if (temp % 10 == 9) {
q.Enqueue(temp * 10 + 8);
q.Enqueue(temp * 10 + 9);
} else {
q.Enqueue(temp * 10 + temp % 10 - 1);
q.Enqueue(temp * 10 + temp % 10);
q.Enqueue(temp * 10 + temp % 10 + 1);
}
}
Console.WriteLine(temp);
}
}
|
[["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 28, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 28, 0, 16, 31, 16, 12, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 109], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 12, 203]]
| 8
| 228
| 10
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var K = int.Parse(ReadLine());
var que = new Queue<long>();
for (int i = 1; i <= 9; i++)
que.Enqueue(i);
for (int i = 1;; i++) {
var num = que.Dequeue();
if (num % 10 != 0)
que.Enqueue(num * 10 + num - 1);
que.Enqueue(num * 10 + num);
if (num % 10 != 9)
que.Enqueue(num * 10 + num + 1);
if (i == K) {
WriteLine(num);
return;
}
}
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var K = int.Parse(ReadLine());
var que = new Queue<long>();
for (int i = 1; i <= 9; i++)
que.Enqueue(i);
var num = 0L;
for (int i = 1; i <= K; i++) {
num = que.Dequeue();
if (num % 10 != 0)
que.Enqueue(num * 10 + num % 10 - 1);
que.Enqueue(num * 10 + num % 10);
if (num % 10 != 9)
que.Enqueue(num * 10 + num % 10 + 1);
}
WriteLine(num);
}
}
}
|
[["+", 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], ["+", 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], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 28, 0, 16, 31, 16, 12, 16, 17, 109], ["+", 0, 28, 0, 16, 31, 16, 12, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 12, 16, 17, 109], ["+", 3, 4, 0, 28, 0, 16, 12, 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, 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], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 180
| 27
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
long[][] dp;
public void Solve(Scanner sc) {
int K = sc.Int;
dp = Create(10, () => new long[13]);
for (int i = 0; i < 10; i++)
dp[i][0] = 1;
for (int i = 1; i < 12; i++) {
for (int k = 0; k < 10; k++) {
for (int m = Max(0, k - 1); m < Min(10, k + 2); m++) {
dp[k][i] += dp[m][i - 1];
}
}
}
long r = 3234566668, l = 0;
while (r - l > 1) {
var m = (r + l) / 2;
var s = m.ToString();
long rt = 0;
//先頭を0
for (int i = 0; i <= s.Length - 2; i++)
for (int j = 1; j < 10; j++)
rt += dp[j][i];
for (int j = 1; j < s[0] - '0'; j++)
rt += dp[j][s.Length - 1];
var c = N(m) + rt;
if (c >= K)
r = m;
else
l = m;
}
WriteLine(r);
}
long N(long k) {
if (k < 10)
return 1;
var s = k.ToString();
long rt = 0;
for (int i = 0; i < 10; i++) {
if (i < s[1] - '0' && Abs(s[0] - '0' - i) <= 1) {
rt += dp[i][s.Length - 2];
}
}
if (Abs(s[1] - s[0]) <= 1)
rt += N(int.Parse(s.Substring(1)));
return rt;
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
long[][] dp;
public void Solve(Scanner sc) {
int K = sc.Int;
dp = Create(10, () => new long[13]);
for (int i = 0; i < 10; i++)
dp[i][0] = 1;
for (int i = 1; i < 12; i++) {
for (int k = 0; k < 10; k++) {
for (int m = Max(0, k - 1); m < Min(10, k + 2); m++) {
dp[k][i] += dp[m][i - 1];
}
}
}
long r = 3234566668, l = 0;
while (r - l > 1) {
var m = (r + l) / 2;
var s = m.ToString();
long rt = 0;
//先頭を0
for (int i = 0; i <= s.Length - 2; i++)
for (int j = 1; j < 10; j++)
rt += dp[j][i];
for (int j = 1; j < s[0] - '0'; j++)
rt += dp[j][s.Length - 1];
var c = N(s) + rt;
if (c >= K)
r = m;
else
l = m;
}
WriteLine(r);
}
long N(string s) {
if (s.Length == 1)
return 1;
// var s = k.ToString();
long rt = 0;
for (int i = 0; i < 10; i++) {
if (i < s[1] - '0' && Abs(s[0] - '0' - i) <= 1) {
rt += dp[i][s.Length - 2];
}
}
if (Abs(s[1] - s[0]) <= 1)
rt += N(s.Substring(1));
return rt;
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
[["-", 0, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 141, 22], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 141, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 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, 203], ["-", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 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, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 203], ["-", 64, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 205, 199], ["-", 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, 25]]
| 8
| 1,968
| 28
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver {
long ans = -1;
int Fun(bool f, int d, int p, int x, long v) {
if (p == 0) {
if (x == 0) {
ans = v;
return -1;
}
return 1;
}
int ret = 0;
int o = 0;
if (f) {
o = Fun(true, -1, p - 1, x, 0);
if (o == -1)
return -1;
x -= o;
ret += o;
}
for (int nd = 0; nd < 10; nd++)
if (f && nd > 0 || !f && Math.Abs(nd - d) < 2) {
o = Fun(false, nd, p - 1, x, v * 10 + Math.Max(0, nd));
if (o == -1)
return -1;
x -= o;
ret += o;
}
return ret;
}
public void Solve() {
// int n = ReadInt();
Fun(true, -1, 10, 15, 0);
Write(ans);
}
#region Main
protected static TextReader reader;
protected static TextWriter writer;
static void Main() {
#if DEBUG
reader = new StreamReader("..\\..\\input.txt");
// reader = new StreamReader(Console.OpenStandardInput());
writer = Console.Out;
// writer = new StreamWriter("..\\..\\output.txt");
#else
reader = new StreamReader(Console.OpenStandardInput());
writer = new StreamWriter(Console.OpenStandardOutput());
// reader = new StreamReader("input.txt");
// writer = new StreamWriter("output.txt");
#endif
try {
new Solver().Solve();
// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
// thread.Start();
// thread.Join();
} catch (Exception ex) {
#if DEBUG
Console.WriteLine(ex);
#else
throw;
#endif
}
reader.Close();
writer.Close();
}
#endregion
#region Read / Write
private static Queue<string> currentLineTokens = new Queue<string>();
private static string[] ReadAndSplitLine() {
return reader.ReadLine().Split(
new[] {
' ',
'\t',
},
StringSplitOptions.RemoveEmptyEntries);
}
public static string ReadToken() {
while (currentLineTokens.Count == 0)
currentLineTokens = new Queue<string>(ReadAndSplitLine());
return currentLineTokens.Dequeue();
}
public static int ReadInt() { return int.Parse(ReadToken()); }
public static long ReadLong() { return long.Parse(ReadToken()); }
public static double ReadDouble() {
return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] ReadIntArray() {
return ReadAndSplitLine().Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return ReadAndSplitLine().Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return ReadAndSplitLine()
.Select(s => double.Parse(s, CultureInfo.InvariantCulture))
.ToArray();
}
public static int[][] ReadIntMatrix(int numberOfRows) {
int[][] matrix = new int [numberOfRows][];
for (int i = 0; i < numberOfRows; i++)
matrix[i] = ReadIntArray();
return matrix;
}
public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) {
int[][] matrix = ReadIntMatrix(numberOfRows);
int[][] ret = new int[matrix[0].Length][];
for (int i = 0; i < ret.Length; i++) {
ret[i] = new int[numberOfRows];
for (int j = 0; j < numberOfRows; j++)
ret[i][j] = matrix[j][i];
}
return ret;
}
public static string[] ReadLines(int quantity) {
string[] lines = new string[quantity];
for (int i = 0; i < quantity; i++)
lines[i] = reader.ReadLine().Trim();
return lines;
}
public static void WriteArray<T>(IEnumerable<T> array) {
writer.WriteLine(string.Join(" ", array));
}
public static void Write(params object[] array) { WriteArray(array); }
public static void WriteLines<T>(IEnumerable<T> array) {
foreach (var a in array)
writer.WriteLine(a);
}
private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> {
public new TValue this[TKey key] {
get { return ContainsKey(key) ? base[key] : default(TValue);
}
set { base[key] = value; }
}
}
private static T[] Init<T>(int size)
where T : new() {
var ret = new T[size];
for (int i = 0; i < size; i++)
ret[i] = new T();
return ret;
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver {
long ans = -1;
int Fun(bool f, int d, int p, int x, long v) {
if (p == 0) {
if (x == 0) {
ans = v;
return -1;
}
return 1;
}
int ret = 0;
int o = 0;
if (f) {
o = Fun(true, -1, p - 1, x, 0);
if (o == -1)
return -1;
x -= o;
ret += o;
}
for (int nd = 0; nd < 10; nd++)
if (f && nd > 0 || !f && Math.Abs(nd - d) < 2) {
o = Fun(false, nd, p - 1, x, v * 10 + Math.Max(0, nd));
if (o == -1)
return -1;
x -= o;
ret += o;
}
return ret;
}
public void Solve() {
int n = ReadInt();
Fun(true, -1, 10, n, 0);
Write(ans);
}
#region Main
protected static TextReader reader;
protected static TextWriter writer;
static void Main() {
#if DEBUG
reader = new StreamReader("..\\..\\input.txt");
// reader = new StreamReader(Console.OpenStandardInput());
writer = Console.Out;
// writer = new StreamWriter("..\\..\\output.txt");
#else
reader = new StreamReader(Console.OpenStandardInput());
writer = new StreamWriter(Console.OpenStandardOutput());
// reader = new StreamReader("input.txt");
// writer = new StreamWriter("output.txt");
#endif
try {
new Solver().Solve();
// var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
// thread.Start();
// thread.Join();
} catch (Exception ex) {
#if DEBUG
Console.WriteLine(ex);
#else
throw;
#endif
}
reader.Close();
writer.Close();
}
#endregion
#region Read / Write
private static Queue<string> currentLineTokens = new Queue<string>();
private static string[] ReadAndSplitLine() {
return reader.ReadLine().Split(
new[] {
' ',
'\t',
},
StringSplitOptions.RemoveEmptyEntries);
}
public static string ReadToken() {
while (currentLineTokens.Count == 0)
currentLineTokens = new Queue<string>(ReadAndSplitLine());
return currentLineTokens.Dequeue();
}
public static int ReadInt() { return int.Parse(ReadToken()); }
public static long ReadLong() { return long.Parse(ReadToken()); }
public static double ReadDouble() {
return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
}
public static int[] ReadIntArray() {
return ReadAndSplitLine().Select(int.Parse).ToArray();
}
public static long[] ReadLongArray() {
return ReadAndSplitLine().Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
return ReadAndSplitLine()
.Select(s => double.Parse(s, CultureInfo.InvariantCulture))
.ToArray();
}
public static int[][] ReadIntMatrix(int numberOfRows) {
int[][] matrix = new int [numberOfRows][];
for (int i = 0; i < numberOfRows; i++)
matrix[i] = ReadIntArray();
return matrix;
}
public static int[][] ReadAndTransposeIntMatrix(int numberOfRows) {
int[][] matrix = ReadIntMatrix(numberOfRows);
int[][] ret = new int[matrix[0].Length][];
for (int i = 0; i < ret.Length; i++) {
ret[i] = new int[numberOfRows];
for (int j = 0; j < numberOfRows; j++)
ret[i][j] = matrix[j][i];
}
return ret;
}
public static string[] ReadLines(int quantity) {
string[] lines = new string[quantity];
for (int i = 0; i < quantity; i++)
lines[i] = reader.ReadLine().Trim();
return lines;
}
public static void WriteArray<T>(IEnumerable<T> array) {
writer.WriteLine(string.Join(" ", array));
}
public static void Write(params object[] array) { WriteArray(array); }
public static void WriteLines<T>(IEnumerable<T> array) {
foreach (var a in array)
writer.WriteLine(a);
}
private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue> {
public new TValue this[TKey key] {
get { return ContainsKey(key) ? base[key] : default(TValue);
}
set { base[key] = value; }
}
}
private static T[] Init<T>(int size)
where T : new() {
var ret = new T[size];
for (int i = 0; i < size; i++)
ret[i] = new T();
return ret;
}
#endregion
}
|
[["+", 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, 213, 63, 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], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,040
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramE {
static void Main() {
int n = NextInt, k = NextInt, c = NextInt;
var line = Line;
var left = new List<int>();
var right = new List<int>();
for (int i = 0; left.Count < k; i++) {
if (line[i] == 'o') {
left.Add(i);
i += c;
}
}
for (int i = n - 1; right.Count < k; i--) {
if (line[i] == 'o') {
right.Add(i);
i -= c;
}
}
right.Reverse();
System.Console.WriteLine(
string.Join("\n", Enumerable.Range(1, k)
.Where(i => left[i - 1] == right[i - 1])
.Select(i => left[i - 1])));
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
public static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, mod - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % mod));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramE {
static void Main() {
int n = NextInt, k = NextInt, c = NextInt;
var line = Line;
var left = new List<int>();
var right = new List<int>();
for (int i = 0; left.Count < k; i++) {
if (line[i] == 'o') {
left.Add(i);
i += c;
}
}
for (int i = n - 1; right.Count < k; i--) {
if (line[i] == 'o') {
right.Add(i);
i -= c;
}
}
right.Reverse();
System.Console.WriteLine(string.Join(
"\n", left.Where((a, i) => a == right[i]).Select(a => a + 1)));
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
public static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, mod - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % mod));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
[["-", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 21], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 22], ["-", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 24], ["+", 0, 28, 0, 218, 54, 55, 0, 220, 141, 22], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 21], ["+", 3, 4, 0, 28, 0, 218, 54, 55, 0, 25], ["-", 0, 28, 0, 218, 8, 16, 31, 204, 205, 22], ["-", 0, 218, 8, 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], ["-", 0, 218, 8, 16, 31, 204, 206, 207, 0, 73], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 204, 205, 22], ["-", 0, 28, 0, 218, 8, 204, 206, 207, 0, 70], ["-", 8, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 8, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 72], ["-", 0, 28, 0, 218, 8, 204, 206, 207, 0, 73]]
| 8
| 1,617
| 31
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
int N, K, C;
sc.Make(out N, out K, out C);
var S = ReadLine();
int[] L = new int[2 * N + 1], R = new int[2 * N + 1]; // i),[i
for (int i = 0; i < N; i++) {
chmax(ref L[i + 1], L[i]);
if (S[i] == 'x')
continue;
chmax(ref L[i + C + 1], L[i] + 1);
}
for (int i = N - 1; i >= 0; i--) {
chmax(ref R[i], R[i + 1]);
if (S[i] == 'x')
continue;
chmax(ref R[i], R[i + C + 1] + 1);
}
var res = new List<int>();
for (int i = 0; i < N; i++) {
if (S[i] == 'o') {
if (L[i + C] + R[i + 1] >= K)
continue;
if (L[i] + R[i] >= K)
res.Add(i + 1);
}
}
if (res.Any())
Console.WriteLine(string.Join("\n", res));
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;
class Solver {
public void Solve(Scanner sc) {
int N, K, C;
sc.Make(out N, out K, out C);
var S = ReadLine();
int[] L = new int[2 * N + 1], R = new int[2 * N + 1]; // i),[i
for (int i = 0; i < N; i++) {
chmax(ref L[i + 1], L[i]);
if (S[i] == 'x')
continue;
chmax(ref L[i + C + 1], L[i] + 1);
}
for (int i = N; i < 2 * N; i++)
chmax(ref L[i + 1], L[i]);
for (int i = N - 1; i >= 0; i--) {
chmax(ref R[i], R[i + 1]);
if (S[i] == 'x')
continue;
chmax(ref R[i], R[i + C + 1] + 1);
}
var res = new List<int>();
for (int i = 0; i < N; i++) {
if (S[i] == 'o') {
if (L[i + C] + R[i + 1] >= K)
continue;
if (L[i] + R[i] >= K)
res.Add(i + 1);
}
}
if (res.Any())
Console.WriteLine(string.Join("\n", res));
}
}
#region Template
public static class Template {
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver().Solve(new Scanner());
Console.Out.Flush();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T a, ref T b) {
var t = b;
b = a;
a = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(this IList<T> A, int i, int j) {
var t = A[i];
A[i] = A[j];
A[j] = t;
}
public static T[] Shuffle<T>(this IList<T> A) {
T[] rt = A.ToArray();
Random rnd = new Random();
for (int i = rt.Length - 1; i >= 1; i--)
swap(ref rt[i], ref rt[rnd.Next(i + 1)]);
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f();
return rt;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<int, T> f) {
var rt = new T[n];
for (var i = 0; i < rt.Length; ++i)
rt[i] = f(i);
return rt;
}
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
}
public class Scanner {
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
public int[] ArrInt1D(int n) => Create(n, () => Int);
public long[] ArrLong1D(int n) => Create(n, () => Long);
public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
// public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1,
// v2); } public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2,
// out T3 v3); return (v1, v2, v3); } public (T1, T2, T3, T4) Make<T1, T2, T3,
// T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2,
// v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public void Deconstruct(out T1 a, out T2 b) {
a = v1;
b = v2;
}
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() {}
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
public void Deconstruct(out T1 a, out T2 b, out T3 c) {
Deconstruct(out a, out b);
c = v3;
}
}
#endregion
|
[["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 31, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 48], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 8, 196, 0, 7, 8, 1, 0, 213, 63, 22], ["+", 0, 7, 8, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 1, 0, 213, 3, 4, 0, 28, 0, 275], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 72], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 1, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 7, 8, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22]]
| 8
| 1,848
| 32
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace q5 {
class Program {
static void Main(string[] args) {
var input1 =
Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
var N = input1[0];
var K = input1[1];
var C = input1[2];
var S = Console.ReadLine().Trim().Select(x => x == 'o').ToArray();
var counts = new int[N + 1];
var poss1 = new int[K];
var poss2 = new int[K];
var c = 0;
for (var i = 0; i < K; i++) {
var sav = c;
for (var j = c; j < N; j++) {
if (S[j]) {
c = j;
break;
}
}
if (sav == c)
return;
poss1[i] = c;
c = c + C + 1;
}
c = N - 1;
for (var i = K - 1; i >= 0; i--) {
var sav = c;
for (var j = c; j >= 0; j--) {
if (S[j]) {
c = j;
break;
}
}
if (sav == c)
return;
poss2[i] = c;
c = c - C - 1;
}
for (var i = 0; i < K; i++) {
if (poss1[i] == poss2[i]) {
Console.WriteLine(i);
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace q5 {
class Program {
static void Main(string[] args) {
var input1 =
Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
var N = input1[0];
var K = input1[1];
var C = input1[2];
var S = Console.ReadLine().Trim().Select(x => x == 'o').ToArray();
var counts = new int[N + 1];
var poss1 = new int[K];
var poss2 = new int[K];
var c = 0;
for (var i = 0; i < K; i++) {
var hit = false;
for (var j = c; j < N; j++) {
if (S[j]) {
hit = true;
c = j;
break;
}
}
if (!hit)
return;
poss1[i] = c;
c = c + C + 1;
}
c = N - 1;
for (var i = K - 1; i >= 0; i--) {
var hit = false;
for (var j = c; j >= 0; j--) {
if (S[j]) {
hit = true;
c = j;
break;
}
}
if (!hit)
return;
poss2[i] = c;
c = c - C - 1;
}
for (var i = 0; i < K; i++) {
if (poss1[i] == poss2[i]) {
Console.WriteLine(poss1[i] + 1);
}
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["+", 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, 211, 0, 146], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111], ["+", 0, 7, 8, 196, 0, 57, 15, 241, 0, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 204, 205, 22], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 70], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 359
| 31
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { ABC161.E(); }
class ABC161 {
public static void A() {
var X = Read.Int();
var Y = Read.Int();
var Z = Read.Int();
Console.WriteLine("{0} {1} {2}", Z, X, Y);
}
public static void B() {
var N = Read.Int();
var M = Read.Int();
var A = Read.IntN();
Array.Sort(A);
var total = A.Sum();
Console.WriteLine(A[N - M] * 4 * M < total ? "No" : "Yes");
}
public static void C() {
var N = Read.Long();
var K = Read.Long();
var a = N % K;
Console.WriteLine(Math.Min(a, K - a));
}
public static void D() {
var K = Read.Int();
var list = new List<long>();
for (int keta = 1; keta <= 10; ++keta) {
for (int i = 1; i <= 9; ++i) {
D_Loop(keta, i, 1, list);
}
}
Console.WriteLine(list[K - 1]);
}
static void D_Loop(int keta, long x, int current, List<long> list) {
if (current == keta) {
list.Add(x);
return;
}
long last = x % 10;
if (last > 0) {
D_Loop(keta, x * 10 + last - 1, current + 1, list);
}
D_Loop(keta, x * 10 + last, current + 1, list);
if (last < 9) {
D_Loop(keta, x * 10 + last + 1, current + 1, list);
}
}
public static void E() {
var N = Read.Int();
var K = Read.Int();
var C = Read.Int();
var S = Read.Str();
var dp = new int[N + C + 2];
for (int i = N; i > 0; --i) {
dp[i] = dp[i + 1];
if (S[i - 1] == 'o') {
dp[i] = Math.Max(dp[i], dp[i + C + 1] + 1);
}
}
if (dp[1] > K) {
return;
}
int currentCount = 0;
int minNext = 0;
for (int i = 1; i <= N; ++i) {
if (S[i - 1] == 'o') {
currentCount++;
minNext = i + C;
}
if (dp[i] > dp[i + 1]) {
if (currentCount == 1) {
Console.WriteLine(i);
}
i = minNext;
currentCount = 0;
}
}
// Dictionary<int, HashSet<int>> dict = new Dictionary<int,
// HashSet<int>>(); for(int i = 1; i <= N; ++i)
//{
// if (S[i - 1] == 'o')
// {
// var v = dp[i];
// if (!dict.ContainsKey(v)) { dict.Add(v, new HashSet<int>()); }
// dict[v].Add(i);
// }
//}
// foreach(var h in dict.OrderBy(x => -x.Key))
//{
// if (h.Value.Count == 1) { Console.WriteLine(h.Value.First()); }
//}
}
public static void F() {
var N = Read.Long();
var divN1 = Util.Dividor(N - 1);
var divN = Util.Dividor(N);
long total = 0;
foreach (var d in divN) {
var X = N;
while (X % d == 0) {
X /= d;
}
if (X % d == 1) {
total++;
}
}
Console.WriteLine(total + divN1.Count);
}
}
class Util {
public static List<long> Dividor(long N) {
var list = new List<long>();
if (N > 1) {
list.Add(N);
}
for (long i = 2; i <= 1000000; ++i) {
if (i * i > N) {
break;
}
if (N % i == 0) {
list.Add(i);
var j = N / i;
if (i != j) {
list.Add(j);
}
}
}
return list;
}
public static long Power(long a, long n, long p) {
long res = 1;
long mult = a;
for (int i = 0; i < 40; ++i) {
if ((n & ((long)1 << i)) > 0) {
res = (res * mult) % p;
}
mult = (mult * mult) % p;
}
return res;
}
public static long Inverse(long a, long p) {
long b = p, c = 1, d = 0, e = 0, f = 0;
while (b != 0) {
e = a / b;
f = b;
b = a - e * b;
a = f;
f = d;
d = c - e * d;
c = f;
}
c %= p;
return c + (c < 0 ? p : 0);
}
}
struct MOD {
public static long P = 1000000007;
public readonly long V;
public MOD(long a) { this.V = a; }
public static implicit operator MOD(long a) { return new MOD(a); }
public static MOD operator +(MOD a, MOD b) {
return new MOD((a.V + b.V) % P);
}
public static MOD operator -(MOD a, MOD b) {
return new MOD((a.V - b.V + P) % P);
}
public static MOD operator *(MOD a, MOD b) {
return new MOD((a.V * b.V) % P);
}
public static MOD operator /(MOD a, MOD b) {
return new MOD((a.V * b.Inverse().V) % P);
}
public MOD Inverse() { return Util.Inverse(V, P); }
public MOD Power(long n) { return Util.Power(V, n, P); }
public override string ToString() { return V.ToString(); }
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { ABC161.E(); }
class ABC161 {
public static void A() {
var X = Read.Int();
var Y = Read.Int();
var Z = Read.Int();
Console.WriteLine("{0} {1} {2}", Z, X, Y);
}
public static void B() {
var N = Read.Int();
var M = Read.Int();
var A = Read.IntN();
Array.Sort(A);
var total = A.Sum();
Console.WriteLine(A[N - M] * 4 * M < total ? "No" : "Yes");
}
public static void C() {
var N = Read.Long();
var K = Read.Long();
var a = N % K;
Console.WriteLine(Math.Min(a, K - a));
}
public static void D() {
var K = Read.Int();
var list = new List<long>();
for (int keta = 1; keta <= 10; ++keta) {
for (int i = 1; i <= 9; ++i) {
D_Loop(keta, i, 1, list);
}
}
Console.WriteLine(list[K - 1]);
}
static void D_Loop(int keta, long x, int current, List<long> list) {
if (current == keta) {
list.Add(x);
return;
}
long last = x % 10;
if (last > 0) {
D_Loop(keta, x * 10 + last - 1, current + 1, list);
}
D_Loop(keta, x * 10 + last, current + 1, list);
if (last < 9) {
D_Loop(keta, x * 10 + last + 1, current + 1, list);
}
}
public static void E() {
var N = Read.Int();
var K = Read.Int();
var C = Read.Int();
var S = Read.Str();
var dp = new int[N + C + 2];
for (int i = N; i > 0; --i) {
dp[i] = dp[i + 1];
if (S[i - 1] == 'o') {
dp[i] = Math.Max(dp[i], dp[i + C + 1] + 1);
}
}
if (dp[1] > K) {
return;
}
int currentCount = 0;
int minNext = 0;
for (int i = 1; i <= N; ++i) {
if (S[i - 1] == 'o') {
currentCount++;
if (currentCount == 1) {
minNext = i + C;
}
}
if (dp[i] > dp[i + 1]) {
if (currentCount == 1) {
Console.WriteLine(i);
i += C;
} else {
i = Math.Max(i, minNext);
}
currentCount = 0;
}
}
// Dictionary<int, HashSet<int>> dict = new Dictionary<int,
// HashSet<int>>(); for(int i = 1; i <= N; ++i)
//{
// if (S[i - 1] == 'o')
// {
// var v = dp[i];
// if (!dict.ContainsKey(v)) { dict.Add(v, new HashSet<int>()); }
// dict[v].Add(i);
// }
//}
// foreach(var h in dict.OrderBy(x => -x.Key))
//{
// if (h.Value.Count == 1) { Console.WriteLine(h.Value.First()); }
//}
}
public static void F() {
var N = Read.Long();
var divN1 = Util.Dividor(N - 1);
var divN = Util.Dividor(N);
long total = 0;
foreach (var d in divN) {
var X = N;
while (X % d == 0) {
X /= d;
}
if (X % d == 1) {
total++;
}
}
Console.WriteLine(total + divN1.Count);
}
}
class Util {
public static List<long> Dividor(long N) {
var list = new List<long>();
if (N > 1) {
list.Add(N);
}
for (long i = 2; i <= 1000000; ++i) {
if (i * i > N) {
break;
}
if (N % i == 0) {
list.Add(i);
var j = N / i;
if (i != j) {
list.Add(j);
}
}
}
return list;
}
public static long Power(long a, long n, long p) {
long res = 1;
long mult = a;
for (int i = 0; i < 40; ++i) {
if ((n & ((long)1 << i)) > 0) {
res = (res * mult) % p;
}
mult = (mult * mult) % p;
}
return res;
}
public static long Inverse(long a, long p) {
long b = p, c = 1, d = 0, e = 0, f = 0;
while (b != 0) {
e = a / b;
f = b;
b = a - e * b;
a = f;
f = d;
d = c - e * d;
c = f;
}
c %= p;
return c + (c < 0 ? p : 0);
}
}
struct MOD {
public static long P = 1000000007;
public readonly long V;
public MOD(long a) { this.V = a; }
public static implicit operator MOD(long a) { return new MOD(a); }
public static MOD operator +(MOD a, MOD b) {
return new MOD((a.V + b.V) % P);
}
public static MOD operator -(MOD a, MOD b) {
return new MOD((a.V - b.V + P) % P);
}
public static MOD operator *(MOD a, MOD b) {
return new MOD((a.V * b.V) % P);
}
public static MOD operator /(MOD a, MOD b) {
return new MOD((a.V * b.Inverse().V) % P);
}
public MOD Inverse() { return Util.Inverse(V, P); }
public MOD Power(long n) { return Util.Power(V, n, P); }
public override string ToString() { return V.ToString(); }
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
[["+", 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, 57, 64, 196, 0, 46], ["+", 64, 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, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 2,303
| 22
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program {
static void Main(string[] args) {
// いろいろ考察した結果
// Nの約数(1除く)とN-1の約数(1除く)それぞれの値をKとおき
// そのKで除算減算の交換処理を行いN=1になるものを求めればそれがKの個数となると思われる。
// 但し1兆もの値に対して 例えば 3等で除算減算してたらTimeOver必死
// →除算で余りが0にならない時は 減算せずに剰余とする。これで解決。
// 前準備
// 1兆の値の約数を求めるのに1から1兆まで除算して余りが0になる値を計算したらどう見てもTimeOver必死
// 1兆の値の約数を求めるのには因数分解が必要
// 1兆の値の因数分解する為には2 から 999983 までの素数(√1兆 =
// 1000000なので)が判明していれば素因数分解が出来る
// 2から999983まので素数取得
// 2から999983まので素数取得する為には2から997までの素数(√999983 =
// 999.9915なので)が判明していればOK
int iRng = 999983; // 調査範囲 999983まで
List<int> lstPrm = new List<int>() {
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997
};
GetPrim(ref lstPrm, iRng);
// 入力
string[] sS = System.Console.ReadLine().Trim().Split(' ');
long iInpN = long.Parse(sS[0]);
//// Debug入力
// List<ClsCal> lstCal = new List<ClsCal>();
// for (long i = 151; i < 1002; i++) { lstCal.Add(new ClsCal() { iN = i });
// }
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
// 解析
List<long> lstFctN0 = new List<long>(); // N の素因数分解要素
GetFact(lstFctN0, lstPrm, iInpN); // N の素因数分解実行
// DitFact(lstFctN0); // N
// の素因数分解のDistinct
List<long> lstYakN0 = new List<long>(); // N の約数要素
GetYaku2(lstYakN0, lstFctN0); // N の約数要素取得
if (!lstYakN0.Contains(iInpN)) {
lstYakN0.Add(iInpN);
} // N の約数にNがなければ追加
List<long> lstFctN1 = new List<long>(); // N-1の素因数分解要素
GetFact(lstFctN1, lstPrm, iInpN - 1); // N-1の素因数分解実行
// DitFact(lstFctN1); //
// N-1の素因数分解のDistinct
List<long> lstYakN1 = new List<long>(); // N-1の約数要素
GetYaku2(lstYakN1, lstFctN1); // N-1の約数要素取得
if (!lstYakN1.Contains(iInpN - 1)) {
lstYakN1.Add(iInpN - 1);
} // N-1の約数にN-1がなければ追加
List<long> lstYak = new List<long>(); // NとN - 1の約数要素
lstYak.AddRange(lstYakN0);
lstYak.AddRange(lstYakN1);
DitFact(lstYak); // NとN - 1の約数要素のDistinct
lstYak.Remove(1L); // 約数1は除外
lstYak.Remove(2L); // 約数2は除外(2は必須)
lstYak.Sort(); // 約数要素のソート
List<long> lstRet = new List<long>(); // Kの一覧
lstRet.Add(2L); // 2は必須
for (int i = 0; i < lstYak.Count; i++) {
long iN = iInpN;
while (true) {
if (iN < lstYak[i]) {
break;
} // 残りがK未満で抜ける
if (iN % lstYak[i] == 0) {
iN = iN / lstYak[i];
} // 割り切れる 時は除算の商 に置き換える
else {
iN = iN % lstYak[i];
} // 割り切れない時は剰余の余りに置き換える
if (iN == 1) {
lstRet.Add(lstYak[i]);
break;
} // 残りが1ならOK
}
}
// 出力
System.Console.WriteLine("{0}", lstRet.Count.ToString().Trim());
//// 入力 検算用
////string[] sS = System.Console.ReadLine().Trim().Split(' ');
////long iN = long.Parse(sS[0]);
//// Debug入力
// List<ClsCal> lstCal = new List<ClsCal>();
// for (long i = 3140; i < 3150; i++) { lstCal.Add(new ClsCal() { iN = i });
// }
//// 解析
// for (int i = 0; i < lstCal.Count; i++)
//{
// for (long iK = 2; iK <= lstCal[i].iN; iK++)
// {
// long iN = lstCal[i].iN;
// while (true)
// {
// if (iN < iK) { break; }
// if (iN % iK == 0) { iN = iN / iK; }
// else { iN = iN - iK; }
// if (iN == 1) { lstCal[i].iK.Add(iK); break; }
// }
// }
//}
sw.Stop();
#if DEBUG
Console.WriteLine();
// DebugDisp(lstCal);
Console.WriteLine("{0}", sw.Elapsed.ToString());
Console.WriteLine("続行するには何かキーを押してください...");
Console.ReadKey();
#endif
}
// Debug表示
private static void DebugDisp(List<ClsCal> lstCal) {
System.Console.WriteLine("{0}", "".ToString().Trim());
for (int i = 0; i < lstCal.Count; i++) // 分割後グループ毎
{
string sOut = "";
// sOut += lstCal[i].iN.ToString().PadLeft(3, ' ') + "=";
// sOut += lstCal[i].iK.Count.ToString().PadLeft(3, ' ') + ":";
// for (int j = 0; j < lstCal[i].iK.Count; j++)
//{
// sOut += lstCal[i].iK[j].ToString().PadLeft(3, ' ') + " ";
//}
sOut += lstCal[i].iN.ToString() + "\t";
sOut += lstCal[i].iK.Count.ToString() + "\t";
for (int j = 0; j < lstCal[i].iK.Count; j++) {
sOut += lstCal[i].iK[j].ToString() + "\t";
}
System.Console.WriteLine("{0}", sOut.ToString());
}
}
// 素数算出
private static void GetPrim(ref List<int> lstPrm, int iRng) {
// 調査対象定義
List<Boolean> lstTag = new List<Boolean>(); // 配列(true:素数 false:合成)
for (int i = 0; i <= iRng / 2; i += 1) {
lstTag.Add(false);
lstTag.Add(true);
} // 予め 2の倍数は false にしておく
// 調査
lstTag[1] = false; // 1は除外
lstTag[2] = true; // 2は素数
for (int i = 1; i < lstPrm.Count; i++) // 調査素数 2は除外しているので3から
{
int iMtS = 2; // 例 3では100000000
int iMtE = iRng / lstPrm[i]; // 例 3では133333333
for (int j = iMtS; j <= iMtE; j++) {
int iTmp = (int)(lstPrm[i] * j);
if (iTmp >= 0 && iTmp <= iRng) {
lstTag[iTmp] = false;
}
}
}
// 結果
List<int> lstNew = new List<int>();
for (int i = 0; i < lstTag.Count; i++) {
if (lstTag[i]) {
lstNew.Add(i);
}
}
lstPrm = lstNew;
}
// 素因数分解
private static void GetFact(List<long> lstFct, List<int> lstPrm, long iN) {
for (int i = 0; i < lstPrm.Count; i++) {
if (iN < lstPrm[i]) {
break;
}
while (true) {
if (iN % lstPrm[i] == 0) {
lstFct.Add(lstPrm[i]);
iN = iN / lstPrm[i];
} else {
break;
}
}
}
if (iN != 0 && iN != 1) {
lstFct.Add(iN);
} // 最後の素数
}
// 素因数分解要素内をDistinctにする
private static void DitFact(List<long> lstFct) {
List<string> lstTmp = new List<string>();
for (int i = 0; i < lstFct.Count; i++) {
lstTmp.Add(lstFct[i].ToString());
}
lstTmp = lstTmp.Distinct().ToList();
lstFct.Clear();
for (int i = 0; i < lstTmp.Count; i++) {
lstFct.Add(long.Parse(lstTmp[i]));
}
}
// 素因数分解から約数取得その2(素因数の各累乗値から Nが大きくても短縮)
private static void GetYaku2(List<long> lstYak, List<long> lstFct) {
List<string> lstDeb = new List<string>();
Dictionary<long, int> dicPrm =
new Dictionary<long, int>(); // 素因数を同じ値の数で管理(Dictionary)
for (int i = 0; i < lstFct.Count;
i++) // A^x B^y C^z のように Aがx個 Bがy個 cがy個 で管理
{
if (dicPrm.ContainsKey(lstFct[i])) {
dicPrm[lstFct[i]] += 1;
} // 同じ値は+1個
else {
dicPrm.Add(lstFct[i], 1);
} // 初めての値は1個
}
List<ClsPrm> lstPrm = new List<ClsPrm>(); // 素因数を同じ値の数で管理(List)
foreach (KeyValuePair<long, int> kvp in dicPrm) {
lstPrm.Add(new ClsPrm() { iPrm = kvp.Key, iPow = kvp.Value, iPed = 0 });
}
int iPowMax = 1; // 約数の数
foreach (KeyValuePair<long, int> kvp in dicPrm) {
iPowMax *= (kvp.Value + 1);
} // 約数の数=各素因数の累乗数+1の和
for (int i = 0; i < iPowMax; i++) // 約数の数だけ回して約数取得計算
{
lstPrm[0].iPed += 1;
for (int j = 0; j < lstPrm.Count; j++) // 今回の各素因数の累乗値取得
{
if (lstPrm[j].iPed >
lstPrm[j].iPow) // この素因数の累乗可能数より大の場合
{
lstPrm[j].iPed = 0; // この素因数の累乗は0クリアで
if (j + 1 < lstPrm.Count) {
lstPrm[j + 1].iPed += 1;
} // 次の素因数の累乗値を+1(次があれば)
}
}
long iRet = 1;
for (int j = 0; j < lstPrm.Count; j++) // 今回の各素因数の累乗値で約数計算
{
for (int k = 0; k < lstPrm[j].iPed;
k++) // 今回の各素因数の累乗値だけ掛け回す 0 なら掛けない
{
iRet *= lstPrm[j].iPrm; // Math.Pow()でもいいけど doble long
// 型変換でオーバーフローは嫌なので
}
}
lstYak.Add(iRet);
}
lstYak.Sort();
}
// 素因数分解から約数取得(素因数の組み合わせから)
private static void GetYaku(List<long> lstYak, List<long> lstFct) {
List<string> lstDeb = new List<string>();
int iCnt = lstFct.Count; // 素因数数
int[] nums = new int[iCnt];
for (int i = 0; i < iCnt; i++) {
nums[i] = i;
}
for (int i = iCnt; i > 0; i--) // 取得する数 iCnt個から少なくしていく
{
var combinations = Combination.Enumerate(
nums, i, withRepetition: false); // 配列内の考えられる組み合わせ
foreach (var elem in combinations) {
long iL = 1;
for (int j = 0; j < elem.Length; j++) {
iL *= lstFct[elem[j]];
} // ある組み合わせの積
lstDeb.Add(iL.ToString()); // それがある約数
}
}
// 重複排除
lstDeb.Sort();
lstDeb = lstDeb.Distinct().ToList();
for (int i = 0; i < lstDeb.Count; i++) {
lstYak.Add(long.Parse(lstDeb[i]));
}
lstYak.Sort();
}
// N個からK個取得する組み合わせ(但しNが大きいと時間が掛かる)
private static class Combination {
public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k,
bool withRepetition) {
if (k == 1) {
foreach (var item in items)
yield return new T[] { item };
yield break;
}
foreach (var item in items) {
var leftside = new T[] { item };
// item よりも前のものを除く (順列と組み合わせの違い)
// 重複を許さないので、unusedから item そのものも取り除く
var unused =
withRepetition
? items
: items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();
foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
yield return leftside.Concat(rightside).ToArray();
}
}
}
}
private class ClsPrm {
public long iPrm { get; set; } = 0L; // 素数
public int iPow { get; set; } = 0; // 累乗
public int iPed { get; set; } = 0; // 累乗カウント値
public override bool Equals(object obj) // 重複排除用定義 .Distinct()用
{
var p = obj as ClsPrm;
if (p == null) {
return false;
}
return (this.iPrm == p.iPrm);
}
public override int GetHashCode() // 重複排除用定義 .Distinct()用
=> iPrm.GetHashCode(); // 重複排除用定義 .Distinct()用
}
private class ClsCal {
public long iN { get; set; } = 0L; // N
public List<long> iK { get; set; } = new List<long>(); // K
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program {
static void Main(string[] args) {
// いろいろ考察した結果
// Nの約数(1除く)とN-1の約数(1除く)それぞれの値をKとおき
// そのKで除算減算の交換処理を行いN=1になるものを求めればそれがKの個数となると思われる。
// 但し1兆もの値に対して 例えば 3等で除算減算してたらTimeOver必死
// →除算で余りが0にならない時は 減算せずに剰余とする。これで解決。
// 約数取得時に素因数分解を行うが素因数が多すぎるとTimeOver発生した為
// 約数取得ロジックを大幅に変更。各素因数の累乗値を元に算出するようにした。
// 今までは素因数の組み合わせで行っていた為、無駄な組み合わせが発生していた。
// 前準備
// 1兆の値の約数を求めるのに1から1兆まで除算して余りが0になる値を計算したらどう見てもTimeOver必死
// 1兆の値の約数を求めるのには因数分解が必要
// 1兆の値の因数分解する為には2 から 999983 までの素数(√1兆 =
// 1000000なので)が判明していれば素因数分解が出来る
// 2から999983まので素数取得
// 2から999983まので素数取得する為には2から997までの素数(√999983 =
// 999.9915なので)が判明していればOK
int iRng = 999983; // 調査範囲 999983まで
List<int> lstPrm = new List<int>() {
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43,
47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997
};
GetPrim(ref lstPrm, iRng);
// 入力
string[] sS = System.Console.ReadLine().Trim().Split(' ');
long iInpN = long.Parse(sS[0]);
//// Debug入力
// List<ClsCal> lstCal = new List<ClsCal>();
// for (long i = 151; i < 1002; i++) { lstCal.Add(new ClsCal() { iN = i });
// }
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
// 解析
List<long> lstFctN0 = new List<long>(); // N の素因数分解要素
GetFact(lstFctN0, lstPrm, iInpN); // N の素因数分解実行
// DitFact(lstFctN0); // N
// の素因数分解のDistinct
List<long> lstYakN0 = new List<long>(); // N の約数要素
GetYaku2(lstYakN0, lstFctN0); // N の約数要素取得
if (!lstYakN0.Contains(iInpN)) {
lstYakN0.Add(iInpN);
} // N の約数にNがなければ追加
List<long> lstFctN1 = new List<long>(); // N-1の素因数分解要素
GetFact(lstFctN1, lstPrm, iInpN - 1); // N-1の素因数分解実行
// DitFact(lstFctN1); //
// N-1の素因数分解のDistinct
List<long> lstYakN1 = new List<long>(); // N-1の約数要素
GetYaku2(lstYakN1, lstFctN1); // N-1の約数要素取得
if (!lstYakN1.Contains(iInpN - 1)) {
lstYakN1.Add(iInpN - 1);
} // N-1の約数にN-1がなければ追加
List<long> lstYak = new List<long>(); // NとN - 1の約数要素
lstYak.AddRange(lstYakN0);
lstYak.AddRange(lstYakN1);
DitFact(lstYak); // NとN - 1の約数要素のDistinct
lstYak.Remove(1L); // 約数1は除外
lstYak.Remove(2L); // 約数2は除外(2は必須)
lstYak.Sort(); // 約数要素のソート
List<long> lstRet = new List<long>(); // Kの一覧
lstRet.Add(2L); // 2は必須
for (int i = 0; i < lstYak.Count; i++) {
long iN = iInpN;
while (true) {
if (iN < lstYak[i]) {
break;
} // 残りがK未満で抜ける
if (iN % lstYak[i] == 0) {
iN = iN / lstYak[i];
} // 割り切れる 時は除算の商 に置き換える
else {
iN = iN % lstYak[i];
} // 割り切れない時は剰余の余りに置き換える
if (iN == 1) {
lstRet.Add(lstYak[i]);
break;
} // 残りが1ならOK
}
}
// 出力
System.Console.WriteLine("{0}", lstRet.Count.ToString().Trim());
//// 入力 検算用
////string[] sS = System.Console.ReadLine().Trim().Split(' ');
////long iN = long.Parse(sS[0]);
//// Debug入力
// List<ClsCal> lstCal = new List<ClsCal>();
// for (long i = 3140; i < 3150; i++) { lstCal.Add(new ClsCal() { iN = i });
// }
//// 解析
// for (int i = 0; i < lstCal.Count; i++)
//{
// for (long iK = 2; iK <= lstCal[i].iN; iK++)
// {
// long iN = lstCal[i].iN;
// while (true)
// {
// if (iN < iK) { break; }
// if (iN % iK == 0) { iN = iN / iK; }
// else { iN = iN - iK; }
// if (iN == 1) { lstCal[i].iK.Add(iK); break; }
// }
// }
//}
sw.Stop();
#if DEBUG
Console.WriteLine();
// DebugDisp(lstCal);
Console.WriteLine("{0}", sw.Elapsed.ToString());
Console.WriteLine("続行するには何かキーを押してください...");
Console.ReadKey();
#endif
}
// Debug表示
private static void DebugDisp(List<ClsCal> lstCal) {
System.Console.WriteLine("{0}", "".ToString().Trim());
for (int i = 0; i < lstCal.Count; i++) // 分割後グループ毎
{
string sOut = "";
// sOut += lstCal[i].iN.ToString().PadLeft(3, ' ') + "=";
// sOut += lstCal[i].iK.Count.ToString().PadLeft(3, ' ') + ":";
// for (int j = 0; j < lstCal[i].iK.Count; j++)
//{
// sOut += lstCal[i].iK[j].ToString().PadLeft(3, ' ') + " ";
//}
sOut += lstCal[i].iN.ToString() + "\t";
sOut += lstCal[i].iK.Count.ToString() + "\t";
for (int j = 0; j < lstCal[i].iK.Count; j++) {
sOut += lstCal[i].iK[j].ToString() + "\t";
}
System.Console.WriteLine("{0}", sOut.ToString());
}
}
// 素数算出
private static void GetPrim(ref List<int> lstPrm, int iRng) {
// 調査対象定義
List<Boolean> lstTag = new List<Boolean>(); // 配列(true:素数 false:合成)
for (int i = 0; i <= iRng / 2; i += 1) {
lstTag.Add(false);
lstTag.Add(true);
} // 予め 2の倍数は false にしておく
// 調査
lstTag[1] = false; // 1は除外
lstTag[2] = true; // 2は素数
for (int i = 1; i < lstPrm.Count; i++) // 調査素数 2は除外しているので3から
{
int iMtS = 2; // 例 3では100000000
int iMtE = iRng / lstPrm[i]; // 例 3では133333333
for (int j = iMtS; j <= iMtE; j++) {
int iTmp = (int)(lstPrm[i] * j);
if (iTmp >= 0 && iTmp <= iRng) {
lstTag[iTmp] = false;
}
}
}
// 結果
List<int> lstNew = new List<int>();
for (int i = 0; i < lstTag.Count; i++) {
if (lstTag[i]) {
lstNew.Add(i);
}
}
lstPrm = lstNew;
}
// 素因数分解
private static void GetFact(List<long> lstFct, List<int> lstPrm, long iN) {
for (int i = 0; i < lstPrm.Count; i++) {
if (iN < lstPrm[i]) {
break;
}
while (true) {
if (iN % lstPrm[i] == 0) {
lstFct.Add(lstPrm[i]);
iN = iN / lstPrm[i];
} else {
break;
}
}
}
if (iN != 0 && iN != 1) {
lstFct.Add(iN);
} // 最後の素数
}
// 素因数分解要素内をDistinctにする
private static void DitFact(List<long> lstFct) {
List<string> lstTmp = new List<string>();
for (int i = 0; i < lstFct.Count; i++) {
lstTmp.Add(lstFct[i].ToString());
}
lstTmp = lstTmp.Distinct().ToList();
lstFct.Clear();
for (int i = 0; i < lstTmp.Count; i++) {
lstFct.Add(long.Parse(lstTmp[i]));
}
}
// 素因数分解から約数取得その2(素因数の各累乗値から Nが大きくても短縮)
private static void GetYaku2(List<long> lstYak, List<long> lstFct) {
if (lstFct.Count == 0) {
return;
} // 素因数がなければ抜ける
List<string> lstDeb = new List<string>();
Dictionary<long, int> dicPrm =
new Dictionary<long, int>(); // 素因数を同じ値の数で管理(Dictionary)
for (int i = 0; i < lstFct.Count;
i++) // A^x B^y C^z のように Aがx個 Bがy個 cがy個 で管理
{
if (dicPrm.ContainsKey(lstFct[i])) {
dicPrm[lstFct[i]] += 1;
} // 同じ値は+1個
else {
dicPrm.Add(lstFct[i], 1);
} // 初めての値は1個
}
List<ClsPrm> lstPrm = new List<ClsPrm>(); // 素因数を同じ値の数で管理(List)
foreach (KeyValuePair<long, int> kvp in dicPrm) {
lstPrm.Add(new ClsPrm() { iPrm = kvp.Key, iPow = kvp.Value, iPed = 0 });
}
int iPowMax = 1; // 約数の数
foreach (KeyValuePair<long, int> kvp in dicPrm) {
iPowMax *= (kvp.Value + 1);
} // 約数の数=各素因数の累乗数+1の和
for (int i = 0; i < iPowMax; i++) // 約数の数だけ回して約数取得計算
{
lstPrm[0].iPed += 1;
for (int j = 0; j < lstPrm.Count; j++) // 今回の各素因数の累乗値取得
{
if (lstPrm[j].iPed >
lstPrm[j].iPow) // この素因数の累乗可能数より大の場合
{
lstPrm[j].iPed = 0; // この素因数の累乗は0クリアで
if (j + 1 < lstPrm.Count) {
lstPrm[j + 1].iPed += 1;
} // 次の素因数の累乗値を+1(次があれば)
}
}
long iRet = 1;
for (int j = 0; j < lstPrm.Count; j++) // 今回の各素因数の累乗値で約数計算
{
for (int k = 0; k < lstPrm[j].iPed;
k++) // 今回の各素因数の累乗値だけ掛け回す 0 なら掛けない
{
iRet *= lstPrm[j].iPrm; // Math.Pow()でもいいけど doble long
// 型変換でオーバーフローは嫌なので
}
}
lstYak.Add(iRet);
}
lstYak.Sort();
}
// 素因数分解から約数取得(素因数の組み合わせから)
private static void GetYaku(List<long> lstYak, List<long> lstFct) {
List<string> lstDeb = new List<string>();
int iCnt = lstFct.Count; // 素因数数
int[] nums = new int[iCnt];
for (int i = 0; i < iCnt; i++) {
nums[i] = i;
}
for (int i = iCnt; i > 0; i--) // 取得する数 iCnt個から少なくしていく
{
var combinations = Combination.Enumerate(
nums, i, withRepetition: false); // 配列内の考えられる組み合わせ
foreach (var elem in combinations) {
long iL = 1;
for (int j = 0; j < elem.Length; j++) {
iL *= lstFct[elem[j]];
} // ある組み合わせの積
lstDeb.Add(iL.ToString()); // それがある約数
}
}
// 重複排除
lstDeb.Sort();
lstDeb = lstDeb.Distinct().ToList();
for (int i = 0; i < lstDeb.Count; i++) {
lstYak.Add(long.Parse(lstDeb[i]));
}
lstYak.Sort();
}
// N個からK個取得する組み合わせ(但しNが大きいと時間が掛かる)
private static class Combination {
public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k,
bool withRepetition) {
if (k == 1) {
foreach (var item in items)
yield return new T[] { item };
yield break;
}
foreach (var item in items) {
var leftside = new T[] { item };
// item よりも前のものを除く (順列と組み合わせの違い)
// 重複を許さないので、unusedから item そのものも取り除く
var unused =
withRepetition
? items
: items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();
foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
yield return leftside.Concat(rightside).ToArray();
}
}
}
}
private class ClsPrm {
public long iPrm { get; set; } = 0L; // 素数
public int iPow { get; set; } = 0; // 累乗
public int iPed { get; set; } = 0; // 累乗カウント値
public override bool Equals(object obj) // 重複排除用定義 .Distinct()用
{
var p = obj as ClsPrm;
if (p == null) {
return false;
}
return (this.iPrm == p.iPrm);
}
public override int GetHashCode() // 重複排除用定義 .Distinct()用
=> iPrm.GetHashCode(); // 重複排除用定義 .Distinct()用
}
private class ClsCal {
public long iN { get; set; } = 0L; // N
public List<long> iK { get; set; } = new List<long>(); // K
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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
| 2,397
| 12
|
using System;
namespace debug {
class Program {
static void Main(string[] args) {
ProgramF2 a = new ProgramF2();
a.main();
}
}
// ABC162
class ProgramE {
public void main() {
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long k = long.Parse(s[1]);
long MOD = 1000000000 + 7;
long[] ans = new long[k];
//最大公約数が大きいほうから数えていく
for (long i = k; i > 0; i--) {
//答えを格納
ans[i - 1] = modpow(k / i, n, MOD);
long x = 2 * i;
//これより大きい公約数をもつ場合は除く(logNの計算時間のはず...)
while (x <= k) {
ans[i - 1] = (ans[i - 1] - ans[x - 1]) % MOD;
x += i;
}
}
//答え算出
long count = 0;
for (int i = 0; i < k; i++) {
count += ans[i] * (i + 1) % MOD;
count %= MOD;
}
Console.WriteLine(count);
}
public long modpow(long a, long n, long mod) {
if (n == 0)
return 1;
if (n % 2 == 0) {
long temp = modpow(a, n / 2, mod);
return temp * temp % mod;
}
return modpow(a, n - 1, mod) * a % mod;
}
}
// ABC162
class ProgramF {
public void main() {
int n = int.Parse(Console.ReadLine());
string[] a = Console.ReadLine().Split(' ');
long INF = -10000000000 + 7; //ありえないケース
// DPで解いていく(
long[,] dp = new long[n + 1, 2]; // i番目までに何個選ぶかを決めて状態遷移、tのときはt
// = i/2, i/2 + 1
dp[0, 0] = 0;
dp[0, 1] = INF;
dp[1, 0] = 0;
dp[1, 1] = long.Parse(a[0]);
dp[2, 0] = long.Parse(a[1]);
dp[2, 1] = INF;
// DP
for (int i = 3; i <= n; i++) {
//偶数の時
if (i % 2 == 0) {
dp[i, 1] = dp[i - 2, 1];
dp[i, 0] = Math.Max(dp[i - 3, 1] + long.Parse(a[i - 1]),
dp[i - 2, 0] + long.Parse(a[i - 1]));
} else {
dp[i, 1] = dp[i - 2, 1] + long.Parse(a[i - 1]);
dp[i, 0] = Math.Max(dp[i - 2, 1], dp[i - 2, 0] + long.Parse(a[i - 1]));
dp[i, 0] = Math.Max(dp[i, 0], dp[i - 3, 0] + long.Parse(a[i - 1]));
if (i > 3)
dp[i, 0] = Math.Max(dp[i, 0], dp[i - 4, 1] + long.Parse(a[i - 1]));
}
}
//答え出力
if (n % 2 == 0)
Console.WriteLine(Math.Max(dp[n - 1, 1], dp[n, 0]));
else
Console.WriteLine(
Math.Max(Math.Max(dp[n, 0], dp[n - 1, 0]), dp[n - 2, 1]));
}
}
// ABC161
class ProgramF2 {
public void main() {
long n = long.Parse(Console.ReadLine());
long count = 2; // nとn-1はすでにカウントしておく(答えなので)
// n-1の約数はすべて満たす(よって、その数と逆数でカウント。平方数に注意)
for (int i = 2; i <= Math.Sqrt(n - 1); i++) {
if ((n - 1) % i == 0) {
if (i * i == n - 1)
count++;
else
count += 2;
}
}
// nの約数にうち小さいほうのみを考える。この数で割り続けたときの余りが1の時だけ足す
for (int i = 2; i <= Math.Sqrt(n); i++) {
if (n % i == 0) {
long t = n;
while (t % i == 0) {
t /= i;
}
if (t % i == 1)
count++;
}
}
Console.WriteLine(count);
}
}
}
|
using System;
namespace debug {
class Program {
static void Main(string[] args) {
ProgramF2 a = new ProgramF2();
a.main();
}
}
// ABC162
class ProgramE {
public void main() {
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long k = long.Parse(s[1]);
long MOD = 1000000000 + 7;
long[] ans = new long[k];
//最大公約数が大きいほうから数えていく
for (long i = k; i > 0; i--) {
//答えを格納
ans[i - 1] = modpow(k / i, n, MOD);
long x = 2 * i;
//これより大きい公約数をもつ場合は除く(logNの計算時間のはず...)
while (x <= k) {
ans[i - 1] = (ans[i - 1] - ans[x - 1]) % MOD;
x += i;
}
}
//答え算出
long count = 0;
for (int i = 0; i < k; i++) {
count += ans[i] * (i + 1) % MOD;
count %= MOD;
}
Console.WriteLine(count);
}
public long modpow(long a, long n, long mod) {
if (n == 0)
return 1;
if (n % 2 == 0) {
long temp = modpow(a, n / 2, mod);
return temp * temp % mod;
}
return modpow(a, n - 1, mod) * a % mod;
}
}
// ABC162
class ProgramF {
public void main() {
int n = int.Parse(Console.ReadLine());
string[] a = Console.ReadLine().Split(' ');
long INF = -10000000000 + 7; //ありえないケース
// DPで解いていく(
long[,] dp = new long[n + 1, 2]; // i番目までに何個選ぶかを決めて状態遷移、tのときはt
// = i/2, i/2 + 1
dp[0, 0] = 0;
dp[0, 1] = INF;
dp[1, 0] = 0;
dp[1, 1] = long.Parse(a[0]);
dp[2, 0] = long.Parse(a[1]);
dp[2, 1] = INF;
// DP
for (int i = 3; i <= n; i++) {
//偶数の時
if (i % 2 == 0) {
dp[i, 1] = dp[i - 2, 1];
dp[i, 0] = Math.Max(dp[i - 3, 1] + long.Parse(a[i - 1]),
dp[i - 2, 0] + long.Parse(a[i - 1]));
} else {
dp[i, 1] = dp[i - 2, 1] + long.Parse(a[i - 1]);
dp[i, 0] = Math.Max(dp[i - 2, 1], dp[i - 2, 0] + long.Parse(a[i - 1]));
dp[i, 0] = Math.Max(dp[i, 0], dp[i - 3, 0] + long.Parse(a[i - 1]));
if (i > 3)
dp[i, 0] = Math.Max(dp[i, 0], dp[i - 4, 1] + long.Parse(a[i - 1]));
}
}
//答え出力
if (n % 2 == 0)
Console.WriteLine(Math.Max(dp[n - 1, 1], dp[n, 0]));
else
Console.WriteLine(
Math.Max(Math.Max(dp[n, 0], dp[n - 1, 0]), dp[n - 2, 1]));
}
}
// ABC161
class ProgramF2 {
public void main() {
long n = long.Parse(Console.ReadLine());
long count = 2; // nとn-1はすでにカウントしておく(答えなので)
if (n == 2) {
Console.WriteLine("1");
return;
}
// n-1の約数はすべて満たす(よって、その数と逆数でカウント。平方数に注意)
for (long i = 2; i <= Math.Sqrt(n - 1); i++) {
if ((n - 1) % i == 0) {
if (i * i == n - 1)
count++;
else
count += 2;
}
}
// nの約数にうち小さいほうのみを考える。iで割ってみて割り切れなくなった時にあまりが1かどうかで判定
for (long i = 2; i <= Math.Sqrt(n); i++) {
if (n % i == 0) {
long t = n;
while (t % i == 0) {
t /= i;
}
if (t % i == 1)
count++;
}
}
Console.WriteLine(count);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199]]
| 8
| 942
| 23
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC161F_2 {
class Program {
static void Main(string[] args) {
var N = RLong;
List<long> divs = new List<long>();
divs.Add(N - 1);
divs.Add(2);
divs.AddRange(GetDivisors(N - 1));
var ds = GetDivisors(N).ToList();
ds.Remove(1);
foreach (var d in ds) {
long n = N;
while (n % d == 0) {
n /= d;
}
if (n % d == 1)
divs.Add(d);
}
divs.Remove(1);
divs = divs.Distinct().ToList();
Draw1D(divs.OrderBy(x => x).ToArray());
Console.WriteLine(divs.Count);
}
/// <summary>
/// 約数の列挙
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static IEnumerable<long> GetDivisors(long num) {
if (num < 1)
yield break;
for (long i = 1; i * i <= num; i++) {
if (num % i == 0) {
yield return i;
if (i * i != num)
yield return (num / i);
}
}
}
}
}
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();
}
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 ABC161F_2 {
class Program {
static void Main(string[] args) {
var N = RLong;
List<long> divs = new List<long>();
divs.Add(N - 1);
divs.Add(2);
divs.AddRange(GetDivisors(N - 1));
var ds = GetDivisors(N).ToList();
ds.Remove(1);
foreach (var d in ds) {
long n = N;
while (n % d == 0) {
n /= d;
}
if (n % d == 1)
divs.Add(d);
}
divs = divs.Distinct().ToList();
divs.Remove(1);
Draw1D(divs.OrderBy(x => x).ToArray());
Console.WriteLine(divs.Count);
}
/// <summary>
/// 約数の列挙
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static IEnumerable<long> GetDivisors(long num) {
if (num < 1)
yield break;
for (long i = 1; i * i <= num; i++) {
if (num % i == 0) {
yield return i;
if (i * i != num)
yield return (num / i);
}
}
}
}
}
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();
}
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, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 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], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 887
| 14
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static long Mod = (long)998244353;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Read();
// Out.Flush();
}
static void Solve() {
var N = Sarray()[0];
var i = 2L;
var hs = new HashSet<long>();
hs.Add(N);
hs.Add(N - 1);
for (; i * i <= N; ++i) {
var t = N;
while (t % i == 0)
t /= i;
if (t % i == 1)
hs.Add(i);
if ((N - 1) % i == 0)
hs.Add((N - 1) / i);
}
WriteLine(hs.Count());
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static long Mod = (long)998244353;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Read();
// Out.Flush();
}
static void Solve() {
var N = Sarray()[0];
var i = 2L;
var hs = new HashSet<long>();
hs.Add(N);
if (N - 1 != 1)
hs.Add(N - 1);
for (; i * i <= N; ++i) {
var t = N;
while (t % i == 0)
t /= i;
if (t % i == 1)
hs.Add(i);
if ((N - 1) % i == 0)
hs.Add((N - 1) / i);
}
WriteLine(hs.Count());
}
}
}
|
[["+", 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, 33], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 265
| 8
|
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;
public static class P {
public static void Main() {
var n = long.Parse(Console.ReadLine());
HashSet<long> res = new HashSet<long>();
{
res.Add(n - 1);
long i;
for (i = 2; i * i < n - 1; i++) {
if ((n - 1) % i != 0)
continue;
res.Add(i);
res.Add((n - 1) / i);
}
if (i * i == n - 1)
res.Add(i);
}
{
res.Add(n);
long i;
for (i = 2; i * i < n; i++) {
if (n % i != 0)
continue;
if (isValid(i, n))
res.Add(i);
if (isValid(n / i, n))
res.Add(n / i);
}
if (i * i == n)
if (isValid(i, n))
res.Add(i);
}
Console.WriteLine(res.Count);
}
static bool isValid(long i, long n) {
var tmp = n;
while (tmp % i == 0)
tmp /= i;
return (tmp - 1) % i == 0;
}
}
|
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;
public static class P {
public static void Main() {
var n = long.Parse(Console.ReadLine());
if (n == 2) {
Console.WriteLine(1);
return;
}
HashSet<long> res = new HashSet<long>();
{
res.Add(n - 1);
long i;
for (i = 2; i * i < n - 1; i++) {
if ((n - 1) % i != 0)
continue;
res.Add(i);
res.Add((n - 1) / i);
}
if (i * i == n - 1)
res.Add(i);
}
{
res.Add(n);
long i;
for (i = 2; i * i < n; i++) {
if (n % i != 0)
continue;
if (isValid(i, n))
res.Add(i);
if (isValid(n / i, n))
res.Add(n / i);
}
if (i * i == n)
if (isValid(i, n))
res.Add(i);
}
Console.WriteLine(res.Count);
}
static bool isValid(long i, long n) {
var tmp = n;
while (tmp % i == 0)
tmp /= i;
return (tmp - 1) % i == 0;
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 334
| 17
|
using System;
using System.Collections.Generic;
namespace F {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
long N = long.Parse(line);
var n1 = Yakusu(N - 1);
var n = Yakusu(N);
var count = 0;
for (int i = 0; i < n.Count; i++) {
var now = N;
while (now % n[i] == 0) {
now = now / n[i];
}
if (now % n[i] == 1) {
count++;
}
}
Console.WriteLine(n1.Count + count);
}
public static List<long> Yakusu(long num) {
var ret = new List<long>();
ret.Add(num);
for (long i = 2; i * i <= num; i++) {
if (num % i == 0) {
ret.Add(i);
if (i * i != num)
ret.Add(num / i);
}
}
return ret;
}
}
}
|
using System;
using System.Collections.Generic;
namespace F {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
long N = long.Parse(line);
var n1 = Yakusu(N - 1);
var n = Yakusu(N);
var count = 0;
for (int i = 0; i < n.Count; i++) {
var now = N;
while (now % n[i] == 0) {
now = now / n[i];
}
if (now % n[i] == 1) {
count++;
}
}
Console.WriteLine(n1.Count + count);
}
public static List<long> Yakusu(long num) {
var ret = new List<long>();
if (num == 1)
return ret;
ret.Add(num);
for (long i = 2; i * i <= num; i++) {
if (num % i == 0) {
ret.Add(i);
if (i * i != num)
ret.Add(num / 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, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35]]
| 8
| 229
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
public class Coder {
public static int[] ReadArray() {
return Array.ConvertAll(Console.ReadLine().Split(' '),
m => Convert.ToInt32(m));
}
public static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); }
public static string ReadStr() { return Console.ReadLine(); }
public static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); }
public static long[] ReadLongArray() {
return Array.ConvertAll(Console.ReadLine().Split(' '),
m => Convert.ToInt64(m));
}
public static void Main() {
long n = ReadLong();
var ans = new HashSet<long>() { n, n - 1 };
for (long i = 2; i * i <= n; i++) {
if ((n - 1) % i == 0) {
ans.Add(i);
ans.Add((n - 1) / i);
}
}
for (long i = 2; i * i <= n; i++) {
var a = n;
while (a % i == 0) {
a /= i;
}
if (a % i == 1)
ans.Add(i);
}
Console.WriteLine(ans.Count);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
public class Coder {
public static int[] ReadArray() {
return Array.ConvertAll(Console.ReadLine().Split(' '),
m => Convert.ToInt32(m));
}
public static int ReadInt() { return Convert.ToInt32(Console.ReadLine()); }
public static string ReadStr() { return Console.ReadLine(); }
public static long ReadLong() { return Convert.ToInt64(Console.ReadLine()); }
public static long[] ReadLongArray() {
return Array.ConvertAll(Console.ReadLine().Split(' '),
m => Convert.ToInt64(m));
}
public static void Main() {
long n = ReadLong();
var ans = new HashSet<long>() { n, n - 1 > 1 ? n - 1 : n };
for (long i = 2; i * i <= n; i++) {
if ((n - 1) % i == 0) {
ans.Add(i);
ans.Add((n - 1) / i);
}
}
for (long i = 2; i * i <= n; i++) {
var a = n;
while (a % i == 0) {
a /= i;
}
if (a % i == 1)
ans.Add(i);
}
Console.WriteLine(ans.Count);
}
}
|
[["+", 0, 230, 10, 229, 0, 41, 15, 16, 17, 47], ["+", 0, 230, 10, 229, 0, 41, 15, 16, 12, 203], ["+", 0, 212, 0, 230, 10, 229, 0, 41, 0, 101], ["+", 0, 230, 10, 229, 0, 41, 64, 16, 31, 22], ["+", 0, 230, 10, 229, 0, 41, 64, 16, 17, 33], ["+", 0, 230, 10, 229, 0, 41, 64, 16, 12, 203], ["+", 0, 212, 0, 230, 10, 229, 0, 41, 0, 102], ["+", 0, 212, 0, 230, 10, 229, 0, 41, 75, 22]]
| 8
| 302
| 8
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0403 {
class Program {
static void Main(string[] args) {
long _targetNumber = GetInput_long()[0];
HashSet<long> _yakusuSet = new HashSet<long>();
HashSet<long> _resultSet = new HashSet<long>();
// Nの約数を取得
for (long i = 2; i * i <= _targetNumber; i++) {
if (_targetNumber % i == 0) {
_yakusuSet.Add(i);
_yakusuSet.Add(_targetNumber / i);
}
}
// Nの約数についての検証
foreach (var data in _yakusuSet) {
long temp = _targetNumber;
while (temp % data == 0) {
temp /= data;
}
if (temp % data == 1) {
_resultSet.Add(data);
}
}
// Nの約数でない場合についての検証
for (long i = 2; i * i <= _targetNumber - 1; i++) {
if ((_targetNumber - 1) % i == 0) {
_resultSet.Add(i);
_resultSet.Add((_targetNumber - 1) / i);
}
}
_resultSet.Add(_targetNumber);
_resultSet.Add(_targetNumber - 1);
Console.WriteLine(_resultSet.Count);
}
#region input
static string[] GetInput_string() {
var input = Console.ReadLine().Split(' ');
return input;
}
static int[] GetInput_int() {
var input = GetInput_string();
var result = new int[input.Length];
for (int i = 0; i < result.Length; i++) {
result[i] = int.Parse(input[i]);
}
return result;
}
static long[] GetInput_long() {
var input = GetInput_string();
var result = new long[input.Length];
for (int i = 0; i < result.Length; i++) {
result[i] = long.Parse(input[i]);
}
return result;
}
#endregion
#region sonota
static void Swap_array<T>(T[] target, int a, int b) {
T temp = target[a];
target[a] = target[b];
target[b] = temp;
}
static void Swap_list<T>(List<T> target, int a, int b) {
T temp = target[a];
target[a] = target[b];
target[b] = temp;
}
#endregion
}
}
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
namespace Atcoder_0403 {
class Program {
static void Main(string[] args) {
long _targetNumber = GetInput_long()[0];
HashSet<long> _yakusuSet = new HashSet<long>();
HashSet<long> _resultSet = new HashSet<long>();
// Nの約数を取得
for (long i = 2; i * i <= _targetNumber; i++) {
if (_targetNumber % i == 0) {
_yakusuSet.Add(i);
_yakusuSet.Add(_targetNumber / i);
}
}
// Nの約数についての検証
foreach (var data in _yakusuSet) {
long temp = _targetNumber;
while (temp % data == 0) {
temp /= data;
}
if (temp % data == 1) {
_resultSet.Add(data);
}
}
// Nの約数でない場合についての検証
for (long i = 2; i * i <= _targetNumber - 1; i++) {
if ((_targetNumber - 1) % i == 0) {
_resultSet.Add(i);
_resultSet.Add((_targetNumber - 1) / i);
}
}
_resultSet.Add(_targetNumber);
if (_targetNumber - 1 > 1)
_resultSet.Add(_targetNumber - 1);
Console.WriteLine(_resultSet.Count);
}
#region input
static string[] GetInput_string() {
var input = Console.ReadLine().Split(' ');
return input;
}
static int[] GetInput_int() {
var input = GetInput_string();
var result = new int[input.Length];
for (int i = 0; i < result.Length; i++) {
result[i] = int.Parse(input[i]);
}
return result;
}
static long[] GetInput_long() {
var input = GetInput_string();
var result = new long[input.Length];
for (int i = 0; i < result.Length; i++) {
result[i] = long.Parse(input[i]);
}
return result;
}
#endregion
#region sonota
static void Swap_array<T>(T[] target, int a, int b) {
T temp = target[a];
target[a] = target[b];
target[b] = temp;
}
static void Swap_list<T>(List<T> target, int a, int b) {
T temp = target[a];
target[a] = target[b];
target[b] = temp;
}
#endregion
}
}
|
[["+", 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, 33], ["+", 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, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 503
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class Program {
static int Solve(long N) {
var set = new HashSet<long> { N - 1, N };
for (long i = 2; i * i <= N - 1; ++i) {
if ((N - 1) % i == 0) {
set.Add(i);
if (i * i < N - 1) {
set.Add((N - 1) / i);
}
}
}
for (long i = 2; i * i <= N; ++i) {
long n = N;
while (n % i == 0) {
n /= i;
}
if (n % i == 1) {
set.Add(i);
}
}
return set.Count;
}
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
Console.WriteLine(Solve(N));
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
static class Program {
static int Solve(long N) {
var set = new HashSet<long> { N };
if (N > 2) {
set.Add(N - 1);
}
for (long i = 2; i * i <= N - 1; ++i) {
if ((N - 1) % i == 0) {
set.Add(i);
if (i * i < N - 1) {
set.Add((N - 1) / i);
}
}
}
for (long i = 2; i * i <= N; ++i) {
long n = N;
while (n % i == 0) {
n /= i;
}
if (n % i == 1) {
set.Add(i);
}
}
return set.Count;
}
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
Console.WriteLine(Solve(N));
}
}
|
[["+", 0, 200, 0, 212, 0, 230, 10, 229, 0, 46], ["+", 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], ["+", 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, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 21], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 22], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 46], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 210
| 19
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramF {
static void Main() {
long n = NextLong;
var bigger = Enumerable.Repeat(false, 1000001).ToArray();
var smaller = Enumerable.Repeat(false, 1000001).ToArray();
var list = new List<long> { n, n - 1 };
for (int i = 2; i <= 1000000; i++)
smaller[i] = (n - 1) % i == 0;
for (int i = 2; i <= 1000000; i++)
bigger[i] = n % i == 0;
if (n - 1 < smaller.Length)
smaller[n - 1] = false;
if (n < bigger.Length)
bigger[n] = false;
for (int i = 2; i <= 1000000; i++) {
if (smaller[i]) {
if (i * i == n - 1)
list.Add(i);
else {
list.Add(i);
list.Add((n - 1) / i);
}
}
if (bigger[i]) {
long tmp = n;
while (tmp % i == 0)
tmp /= i;
if (tmp % i == 1)
list.Add(i);
}
}
System.Console.WriteLine(list.Distinct().Count());
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
public static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, mod - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % mod));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;
namespace AtCoderTemplate {
class ProgramF {
static void Main() {
long n = NextLong;
var bigger = Enumerable.Repeat(false, 1000001).ToArray();
var smaller = Enumerable.Repeat(false, 1000001).ToArray();
var list = new List<long> { n };
if (n != 2)
list.Add(n - 1);
for (int i = 2; i <= 1000000; i++)
smaller[i] = (n - 1) % i == 0;
for (int i = 2; i <= 1000000; i++)
bigger[i] = n % i == 0;
if (n - 1 < smaller.Length)
smaller[n - 1] = false;
if (n < bigger.Length)
bigger[n] = false;
for (int i = 2; i <= 1000000; i++) {
if (smaller[i]) {
if (i * i == n - 1)
list.Add(i);
else {
list.Add(i);
list.Add((n - 1) / i);
}
}
if (bigger[i]) {
long tmp = n;
while (tmp % i == 0)
tmp /= i;
if (tmp % i == 1)
list.Add(i);
}
}
System.Console.WriteLine(list.Distinct().Count());
}
}
}
namespace Library {
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line => Console.ReadLine();
public static string[] StrArr => Line.Split(' ');
public static int NextInt => int.Parse(NextWord());
public static long NextLong => long.Parse(NextWord());
public static List<int> IntList => StrArr.Select(int.Parse).ToList();
public static List<long> LongList => StrArr.Select(long.Parse).ToList();
public static IEnumerable<long[]> TakeLine(int N) {
return Enumerable.Repeat(0, N).Select(
_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
}
public static string NextWord() {
while (!enumerator.MoveNext()) {
enumerator = StrArr.AsEnumerable().GetEnumerator();
}
return enumerator.Current;
}
}
}
namespace Library {
class Modular {
public const int mod = 1000000007;
public readonly long value;
public Modular(long value) { this.value = value; }
public static implicit operator Modular(long a) {
var m = a % mod;
return new Modular((m < 0) ? m + mod : m);
}
public static Modular operator +(Modular a, Modular b) {
return a.value + b.value;
}
public static Modular operator -(Modular a, Modular b) {
return a.value - b.value;
}
public static Modular operator *(Modular a, Modular b) {
return a.value * b.value;
}
public static Modular Pow(Modular a, int n) {
switch (n) {
case 0:
return 1;
case 1:
return a;
default:
var p = Pow(a, n / 2);
return p * p * Pow(a, n % 2);
}
}
public static Modular operator /(Modular a, Modular b) {
return a * Pow(b, mod - 2);
}
private static readonly List<int> facs = new List<int> { 1 };
private static Modular Fac(int n) {
for (int i = facs.Count; i <= n; ++i) {
facs.Add((int)(Math.BigMul(facs.Last(), i) % mod));
}
return facs[n];
}
public static Modular Ncr(int n, int r) {
return (n < r) ? 0 : (n == r) ? 1 : Fac(n) / (Fac(r) * Fac(n - r));
}
public static explicit operator int(Modular a) { return (int)a.value; }
}
}
namespace Library {
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
public static long Sqrt(long n) {
if (n < 0)
return 0;
long a = 0, tmp = 0, b = 0;
for (int i = 62; i >= 0; i -= 2) {
tmp = (b << 1) + 1 <= (n >> i) ? 1 : 0;
a = a << 1 | tmp;
n -= (((b << 1) + 1) * tmp) << i;
b = (b << 1) + tmp + tmp;
}
return a;
}
public static long Nck(int n, int k) {
if (k == 0)
return 1;
if (n == 0)
return 0;
return n * Nck(n - 1, k - 1) / k;
}
}
}
namespace Library {
public class PriorityQueue<T> {
readonly List<T> _heap = new List<T>();
readonly Comparison<T> _comparison;
public PriorityQueue(Comparison<T> comparison) { _comparison = comparison; }
public PriorityQueue() : this(Comparer<T>.Default.Compare) {}
public PriorityQueue(IComparer<T> comparer) : this(comparer.Compare) {}
public void Enqueue(T item) {
_heap.Add(item);
int childID = _heap.Count - 1;
int parentID = (childID - 1) / 2;
while (childID > 0 && _comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
childID = parentID;
parentID = (parentID - 1) / 2;
}
}
public T Dequeue() {
var first = _heap.First();
_heap[0] = _heap.Last();
_heap.RemoveAt(_heap.Count - 1);
int parentID = 0;
int childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
while (childID < _heap.Count &&
_comparison(_heap[parentID], _heap[childID]) > 0) {
Swap(parentID, childID);
parentID = childID;
childID = parentID * 2 + 2;
if (childID >= _heap.Count ||
_comparison(_heap[childID], _heap[childID - 1]) > 0)
childID--;
}
return first;
}
void Swap(int parent, int child) {
var tmp = _heap[parent];
_heap[parent] = _heap[child];
_heap[child] = tmp;
}
public T Peek() { return _heap[0]; }
public int Count => _heap.Count;
public bool Any() { return _heap.Any(); }
public List<T> Data => _heap;
}
}
namespace Library {
public class UnionFind {
public int[] Parents { get; set; }
public UnionFind(int size) {
Parents = Enumerable.Repeat(-1, size).ToArray();
}
public int Find(int num) {
if (Parents[num] < 0)
return num;
Parents[num] = Find(Parents[num]);
return Parents[num];
}
public int Size(int num) { return -Parents[Find(num)]; }
public bool Same(int a, int b) { return Find(a) == Find(b); }
public void Unite(int a, int b) {
int x = Find(a), y = Find(b);
if (Size(x) > Size(y)) {
Parents[x] += Parents[y];
Parents[y] = x;
} else {
Parents[y] += Parents[x];
Parents[x] = y;
}
}
}
}
|
[["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 21], ["+", 0, 200, 0, 212, 0, 230, 10, 229, 0, 46], ["+", 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, 17, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 0, 200, 0, 212, 0, 230, 10, 229, 0, 46], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25]]
| 8
| 1,693
| 15
|
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
class Program {
// Main
static void Main(string[] args) {
//読み込む
long N = long.Parse(Console.ReadLine());
// Nの約数のうち、Kで割った商をKで割った余りが1のものをカウント
/*
即ち、N = pKとしたとき、
p = qK + rと表せるが、(0<=q)
この余りrが1となれば良い
(∵p = qK + 1となれば、Kを引き続けることで答えが1となる)
*/
long divCounterN = 0;
//(N-1)の約数をカウント
long divCounterN2 = 0;
//約数を数え上げ
long root = (long)Math.Sqrt(N);
long root2 = (long)Math.Sqrt(N - 1);
// Nの約数について調査
for (long i = 1; i <= root; i++) {
if (N % i == 0) {
//約数iがKとなる場合についてカウント
if (i != 1) {
long K = i;
long div = N;
while (div % K == 0 && div > 1) {
div /= K;
}
if (div % K == 1) {
divCounterN++;
}
}
//約数N/iについても同様に検証
long K2 = N / i;
long div2 = i;
while (div2 % K2 == 0 && div2 > 1) {
div2 /= K2;
}
if (div2 % K2 == 1) {
divCounterN++;
}
}
}
// N-1の約数を調査
for (long i = 1; i <= root2; i++) {
if ((N - 1) % i == 0) {
divCounterN2++;
}
}
if ((N - 1) != 1) {
divCounterN2 *= 2;
if (root2 * root2 == (N - 1)) {
divCounterN2--;
}
}
/*debug
Console.WriteLine(divCounterN);
Console.WriteLine(divCounterN2);
*/
//両者を加算
long answer = divCounterN + divCounterN2;
//(N-1)の約数1の分を減算(Nを1で割っても余らない)
//(1は、NとN-1の唯一の公約数)
answer--;
Console.WriteLine(answer);
}
}
|
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
class Program {
// Main
static void Main(string[] args) {
//読み込む
long N = long.Parse(Console.ReadLine());
// Nの約数のうち、Kで割った商をKで割った余りが1のものをカウント
/*
即ち、N = pKとしたとき、
p = qK + rと表せるが、(0<=q)
この余りrが1となれば良い
(∵p = qK + 1となれば、Kを引き続けることで答えが1となる)
*/
long divCounterN = 0;
//(N-1)の約数をカウント
long divCounterN2 = 0;
//約数を数え上げ
long root = (long)Math.Sqrt(N);
long root2 = (long)Math.Sqrt(N - 1);
// Nの約数について調査
for (long i = 1; i <= root; i++) {
if (N % i == 0) {
//約数iがKとなる場合についてカウント
if (i != 1) {
long K = i;
long div = N;
while (div % K == 0) {
div /= K;
}
if (div % K == 1) {
divCounterN++;
}
}
//約数N/iについても同様に検証
long K2 = N / i;
long div2 = N;
while (div2 % K2 == 0) {
div2 /= K2;
}
if (div2 % K2 == 1) {
divCounterN++;
}
//平方根の場合は二重に加算していることに注意
if (i * i == N) {
divCounterN--;
}
}
}
// N-1の約数を調査
for (long i = 1; i <= root2; i++) {
if ((N - 1) % i == 0) {
divCounterN2++;
}
}
if ((N - 1) != 1) {
divCounterN2 *= 2;
if (root2 * root2 == (N - 1)) {
divCounterN2--;
}
}
/*debug
Console.WriteLine(divCounterN);
Console.WriteLine(divCounterN2);
*/
//両者を加算
long answer = divCounterN + divCounterN2;
//(N-1)の約数1の分を減算(Nを1で割っても余らない)
//(1は、NとN-1の唯一の公約数)
answer--;
Console.WriteLine(answer);
}
}
|
[["-", 0, 57, 64, 196, 0, 52, 15, 16, 17, 98], ["-", 64, 196, 0, 52, 15, 16, 12, 16, 31, 22], ["-", 64, 196, 0, 52, 15, 16, 12, 16, 17, 47], ["-", 64, 196, 0, 52, 15, 16, 12, 16, 12, 203], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 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, 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, 48], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68]]
| 8
| 309
| 23
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace q6 {
class Program {
static IEnumerable<long> Div(long n) {
var x = 2L;
yield return 1;
while (true) {
if ((x * x) > n)
break;
if (n % x == 0) {
yield return x;
if ((n / x) != x) {
yield return n / x;
}
}
x += 1;
}
yield return n;
}
static void Main(string[] args) {
var N = Convert.ToInt64(Console.ReadLine());
var cnt = 0;
var set = new HashSet<long>();
set.Add(1);
foreach (var k in Div(N).Skip(1)) {
// Console.WriteLine($"d1 {k}");
var n = N;
while (n > k && n % k == 0) {
n = n / k;
}
if (n > k)
n = n % k;
if (n == 0 || n == k) {
// Console.WriteLine($" d1 hit {k}");
set.Add(k);
}
}
foreach (var k in Div(N - 1).Skip(1)) {
// Console.WriteLine($" d2 {k}");
// Console.WriteLine($" d2 hit {k}");
set.Add(k);
}
foreach (var v in set) {
// Console.WriteLine($"res {v}");
}
Console.WriteLine(set.Count);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace q6 {
class Program {
static IEnumerable<long> Div(long n) {
var x = 2L;
yield return 1;
while (true) {
if ((x * x) > n)
break;
if (n % x == 0) {
yield return x;
if ((n / x) != x) {
yield return n / x;
}
}
x += 1;
}
yield return n;
}
static void Main(string[] args) {
var N = Convert.ToInt64(Console.ReadLine());
var cnt = 0;
var set = new HashSet<long>();
set.Add(1);
foreach (var k in Div(N).Skip(1)) {
// Console.WriteLine($"d1 {k}");
var n = N;
while (n > k && n % k == 0) {
n = n / k;
}
if (n > k)
n = n % k;
if (n == 1 || n == k) {
// Console.WriteLine($" d1 hit {k}");
set.Add(k);
}
}
foreach (var k in Div(N - 1).Skip(1)) {
// Console.WriteLine($" d2 {k}");
// Console.WriteLine($" d2 hit {k}");
set.Add(k);
}
set.Remove(0);
set.Remove(-1);
set.Remove(1);
/*
foreach (var v in set.OrderBy(x => x))
{
Console.WriteLine($"res {v}");
}
*/
Console.WriteLine(set.Count);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 266], ["+", 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, 210, 39, 216, 0, 217], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 0, 267], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 241, 0, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 241, 0, 203], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46]]
| 8
| 284
| 27
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program {
const int mod = (int)1e9 + 7;
const double eps = 1e-11;
static void Main() {
Sc sc = new Sc();
var n = sc.L;
int q = (int)Sqrt(n), ans = 2;
for (int i = 2; i <= q; i++) {
if ((n - 1) % i == 0) {
if (i == q) {
ans++;
} else {
ans += 2;
}
} else if ((i < 10 || n % i == 0) && Fu(i, n)) {
ans++;
}
}
Console.WriteLine(ans);
}
static bool Fu(long i, long n) {
long p = n;
while (p > 1) {
if (p % i == 0) {
p /= i;
} else if (p > i) {
p %= i;
} else {
p -= i;
}
}
return p == 1;
}
}
public class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
public object[] Oa {
get { return Console.ReadLine().Split(); }
}
public int[] Ia2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
int.Parse);
}
}
public int[] Ia3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
int.Parse);
}
public int[] Ia3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
int.Parse);
}
public long[] La2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
long.Parse);
}
}
public long[] La3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
long.Parse);
}
public long[] La3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
long.Parse);
}
public double[] Da2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
double.Parse);
}
}
public double[] Da3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
double.Parse);
}
public double[] Da3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
double.Parse);
}
public T[] Arr<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f();
}
return a;
}
public T[] Arr<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i);
}
return a;
}
public T[] Arr<T>(int n, Func<string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(Console.ReadLine().Split());
}
return a;
}
public T[] Arr<T>(int n, Func<int, string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i, Console.ReadLine().Split());
}
return a;
}
}
|
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program {
const int mod = (int)1e9 + 7;
const double eps = 1e-11;
static void Main() {
Sc sc = new Sc();
var n = sc.L;
if (n == 2) {
Console.WriteLine(1);
return;
}
int q = (int)Sqrt(n), ans = 2;
for (int i = 2; i <= q; i++) {
if ((n - 1) % i == 0) {
if (i == q) {
ans++;
} else {
ans += 2;
}
} else if ((i < 10 || n % i == 0) && Fu(i, n)) {
ans++;
}
}
Console.WriteLine(ans);
}
static bool Fu(long i, long n) {
long p = n;
while (p > 1) {
if (p % i == 0) {
p /= i;
} else if (p > i) {
p %= i;
} else {
p -= i;
}
}
return p == 1;
}
}
public class Sc {
public int I {
get { return int.Parse(Console.ReadLine()); }
}
public long L {
get { return long.Parse(Console.ReadLine()); }
}
public double D {
get { return double.Parse(Console.ReadLine()); }
}
public string S {
get { return Console.ReadLine(); }
}
public int[] Ia {
get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); }
}
public long[] La {
get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); }
}
public double[] Da {
get { return Array.ConvertAll(Console.ReadLine().Split(), double.Parse); }
}
public string[] Sa {
get { return Console.ReadLine().Split(); }
}
public object[] Oa {
get { return Console.ReadLine().Split(); }
}
public int[] Ia2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
int.Parse);
}
}
public int[] Ia3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
int.Parse);
}
public int[] Ia3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
int.Parse);
}
public long[] La2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
long.Parse);
}
}
public long[] La3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
long.Parse);
}
public long[] La3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
long.Parse);
}
public double[] Da2 {
get {
return Array.ConvertAll(("0 " + Console.ReadLine() + " 0").Split(),
double.Parse);
}
}
public double[] Da3(int a) {
return Array.ConvertAll((a.ToString() + " " + Console.ReadLine()).Split(),
double.Parse);
}
public double[] Da3(bool a, int b, bool c, int d) {
return Array.ConvertAll(((a ? b.ToString() + " " : "") +
Console.ReadLine() + (c ? " " + d.ToString() : ""))
.Split(),
double.Parse);
}
public T[] Arr<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f();
}
return a;
}
public T[] Arr<T>(int n, Func<int, T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i);
}
return a;
}
public T[] Arr<T>(int n, Func<string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(Console.ReadLine().Split());
}
return a;
}
public T[] Arr<T>(int n, Func<int, string[], T> f) {
var a = new T[n];
for (int i = 0; i < n; i++) {
a[i] = f(i, Console.ReadLine().Split());
}
return a;
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,208
| 17
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC161F.Input;
namespace ABC161F {
static class Input {
private static Func<string, T[]>
Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray();
private static Func<string, T> Convert<T>() {
Type t = typeof(T);
if (t == typeof(string))
return _ => (T)(object)_;
if (t == typeof(int))
return _ => (T)(object) int.Parse(_);
if (t == typeof(long))
return _ => (T)(object) long.Parse(_);
if (t == typeof(double))
return _ => (T)(object) double.Parse(_);
if (t == typeof(string[]))
return _ => (T)(object)_.Split(' ');
if (t == typeof(int[]))
return _ => (T)(object)Cast<int>()(_);
if (t == typeof(long[]))
return _ => (T)(object)Cast<long>()(_);
if (t == typeof(double[]))
return _ => (T)(object)Cast<double>()(_);
throw new NotSupportedException(t + "is not supported.");
}
private static T Convert<T>(string s) => Convert<T>()(s);
private static string String() => Console.ReadLine();
private static string[] String(long rowNumber) =>
new bool [rowNumber].Select(_ => String()).ToArray();
public static void Cin<T>(out T a) => a = Convert<T>(String());
public static void Cin<T1, T2>(out T1 a1, out T2 a2) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
}
public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
}
public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
}
public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4, out T5 a5) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
}
public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2,
out T3 a3, out T4 a4,
out T5 a5, out T6 a6) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
set(v[5], out a6);
}
private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s);
public static void
Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray();
public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) {
l1 = new T1[n];
l2 = new T2[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i]);
}
public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2,
out T3[] l3) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i]);
}
public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2,
out T3[] l3, out T4[] l4) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
l4 = new T4[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i], out l4[i]);
}
public static void Cin<T>(out T[] a) => a = Convert<T[]>(String());
public static void Cin<T>(long h, out T[][] map) => map =
String(h).Select(Convert<T[]>()).ToArray();
}
class Program {
public static void Main(string[] args) {
StreamWriter streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
new Solver().Solve();
Console.Out.Flush();
}
public static void Debug() { new Solver().Solve(); }
}
class Solver {
public void Solve() {
long n;
Cin(out n);
long l = 1;
HashSet<long> divisors = new HashSet<long>();
while (l * l <= n) {
if (n % l == 0) {
divisors.Add(l);
divisors.Add(n / l);
if (l == n / l) {
ans.Add(l);
}
}
l++;
}
divisors.Remove(1);
foreach (long d in divisors) {
long k = n;
while (k % d == 0)
k /= d;
if (k % d == 1 || k / d == 1) {
ans.Add(d);
}
}
add(n - 1);
ans.Remove(1);
ans.Add(2);
ans.Add(n);
Console.WriteLine(ans.Count);
}
void add(long n) {
long l = 1;
while (l * l <= n) {
if (n % l == 0) {
ans.Add(l);
ans.Add(n / l);
}
l++;
}
}
HashSet<long> ans = new HashSet<long>();
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC161F.Input;
namespace ABC161F {
static class Input {
private static Func<string, T[]>
Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray();
private static Func<string, T> Convert<T>() {
Type t = typeof(T);
if (t == typeof(string))
return _ => (T)(object)_;
if (t == typeof(int))
return _ => (T)(object) int.Parse(_);
if (t == typeof(long))
return _ => (T)(object) long.Parse(_);
if (t == typeof(double))
return _ => (T)(object) double.Parse(_);
if (t == typeof(string[]))
return _ => (T)(object)_.Split(' ');
if (t == typeof(int[]))
return _ => (T)(object)Cast<int>()(_);
if (t == typeof(long[]))
return _ => (T)(object)Cast<long>()(_);
if (t == typeof(double[]))
return _ => (T)(object)Cast<double>()(_);
throw new NotSupportedException(t + "is not supported.");
}
private static T Convert<T>(string s) => Convert<T>()(s);
private static string String() => Console.ReadLine();
private static string[] String(long rowNumber) =>
new bool [rowNumber].Select(_ => String()).ToArray();
public static void Cin<T>(out T a) => a = Convert<T>(String());
public static void Cin<T1, T2>(out T1 a1, out T2 a2) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
}
public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
}
public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
}
public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4, out T5 a5) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
}
public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2,
out T3 a3, out T4 a4,
out T5 a5, out T6 a6) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
set(v[5], out a6);
}
private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s);
public static void
Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray();
public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) {
l1 = new T1[n];
l2 = new T2[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i]);
}
public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2,
out T3[] l3) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i]);
}
public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2,
out T3[] l3, out T4[] l4) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
l4 = new T4[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i], out l4[i]);
}
public static void Cin<T>(out T[] a) => a = Convert<T[]>(String());
public static void Cin<T>(long h, out T[][] map) => map =
String(h).Select(Convert<T[]>()).ToArray();
}
class Program {
public static void Main(string[] args) {
StreamWriter streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
new Solver().Solve();
Console.Out.Flush();
}
public static void Debug() { new Solver().Solve(); }
}
class Solver {
public void Solve() {
long n;
Cin(out n);
long l = 1;
HashSet<long> divisors = new HashSet<long>();
while (l * l <= n) {
if (n % l == 0) {
divisors.Add(l);
divisors.Add(n / l);
if (l == n / l) {
ans.Add(l);
}
}
l++;
}
divisors.Remove(1);
foreach (long d in divisors) {
long k = n;
while (k % d == 0)
k /= d;
if (k % d == 1) {
ans.Add(d);
}
}
add(n - 1);
ans.Remove(1);
Console.WriteLine(ans.Count);
}
void add(long n) {
long l = 1;
while (l * l <= n) {
if (n % l == 0) {
ans.Add(l);
ans.Add(n / l);
}
l++;
}
}
HashSet<long> ans = new HashSet<long>();
}
}
|
[["-", 0, 210, 8, 196, 0, 57, 15, 16, 17, 106], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 85], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 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, 203], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,614
| 20
|
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();
}
List<long> ans;
void solve(long a, long b) {
if (a == 1) {
long m = b - 1;
for (long i = 1; i * i <= m; i++) {
if (m % i == 0) {
if (i > 1) {
ans.Add(i);
}
ans.Add(m / i);
}
}
return;
}
if (b % a == 1) {
ans.Add(a);
}
for (int i = 2; i <= 40; i++) {
long le = 0, u = Math.Min(1000010, a + 1);
while (u - le > 1) {
long m = (le + u) / 2;
long s = 1;
for (int j = 0; j < i; j++) {
s *= m;
if (s > a)
break;
}
if (s <= a) {
le = m;
} else {
u = m;
}
}
{
long s = 1;
for (int j = 0; j < i; j++) {
s *= le;
}
if (s == a && b % le == 1) {
ans.Add(le);
}
}
}
}
public void solve() {
long n = sc.Long;
ans = new List<long>();
for (long i = 1; i * i <= n; i++) {
if (n % i == 0) {
solve(i, n / i);
solve(n / i, i);
}
}
Prt(ans.Distinct().Count());
}
}
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();
}
List<long> ans;
void solve(long a, long b) {
if (a == 1) {
long m = b - 1;
for (long i = 1; i * i <= m; i++) {
if (m % i == 0) {
if (i > 1) {
ans.Add(i);
}
if (m / i > 1)
ans.Add(m / i);
}
}
return;
}
if (b % a == 1) {
ans.Add(a);
}
for (int i = 2; i <= 40; i++) {
long le = 0, u = Math.Min(1000010, a + 1);
while (u - le > 1) {
long m = (le + u) / 2;
long s = 1;
for (int j = 0; j < i; j++) {
s *= m;
if (s > a)
break;
}
if (s <= a) {
le = m;
} else {
u = m;
}
}
{
long s = 1;
for (int j = 0; j < i; j++) {
s *= le;
}
if (s == a && b % le == 1) {
ans.Add(le);
}
}
}
}
public void solve() {
long n = sc.Long;
ans = new List<long>();
for (long i = 1; i * i <= n; i++) {
if (n % i == 0) {
solve(i, n / i);
solve(n / i, i);
}
}
Prt(ans.Distinct().Count());
}
}
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, 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, 85], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 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]]
| 8
| 2,499
| 8
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Trim().Split(' ');
Console.WriteLine((input[2] == input[3] && input[4] == input[5]) ? "Yes"
: "No");
}
}
}
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine();
Console.WriteLine((input[2] == input[3] && input[4] == input[5]) ? "Yes"
: "No");
}
}
}
|
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 104], ["-", 0, 213, 3, 4, 0, 28, 0, 252, 0, 253], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25]]
| 8
| 82
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
// int N = int.Parse(line);
if (line[3] == line[4] && line[5] == line[6])
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace A {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
// int N = int.Parse(line);
if (line[2] == line[3] && line[4] == line[5])
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 97
| 8
|
using System;
namespace ABC_160_A_Csharp_ver {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
if (S[3] == S[4] && S[5] == S[6])
Console.WriteLine("Yes");
else
Console.WriteLine("No");
Console.ReadKey();
}
}
}
|
using System;
namespace ABC_160_A_Csharp_ver {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
if (S[2] == S[3] && S[4] == S[5])
Console.WriteLine("Yes");
else
Console.WriteLine("No");
Console.ReadKey();
}
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 78
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var line = Console.ReadLine();
if (CheckSimCoffee(line)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
// Console.WriteLine("hello world");
// while (true)
//{
// var line= Console.ReadLine();
// Console.WriteLine(line);
//}
}
private static bool CheckSimCoffee(string line) {
if (line.Length != 6)
return false;
return line[3] == line[4] && line[5] == line[6];
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var line = Console.ReadLine();
if (CheckSimCoffee(line)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
// Console.WriteLine("hello world");
// while (true)
//{
// var line= Console.ReadLine();
// Console.WriteLine(line);
//}
}
private static bool CheckSimCoffee(string line) {
if (line.Length != 6)
return false;
return line[2] == line[3] && line[4] == line[5];
}
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 133
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
if (s.Length != 6)
return;
if (s[3] == s[4] && s[5] == s[6]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
if (s.Length != 6)
return;
if (s[2] == s[3] && s[4] == s[5]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 94
| 8
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
if (s[0] == s[1] && s[2] == s[3] && s[4] == s[5])
System.Console.WriteLine("Yes");
else
System.Console.WriteLine("No");
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
if (s[2] == s[3] && s[4] == s[5])
System.Console.WriteLine("Yes");
else
System.Console.WriteLine("No");
}
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 60], ["-", 15, 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], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["-", 15, 16, 31, 16, 12, 16, 31, 204, 205, 22], ["-", 31, 16, 12, 16, 31, 204, 206, 207, 0, 70]]
| 8
| 86
| 10
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public static void Main(string[] args) { new A().test(); }
}
public class A {
public void test() {
// スペース区切りの整数の入力
var input = CommonRead.ReadStr();
// 六文字以下は異なる
if (input.Length != 6) {
Console.WriteLine("No");
return;
}
// 3文字目と4文字目
if (input.Substring(2, 1).Equals(input.Substring(3, 1))) {
Console.WriteLine("Yes");
return;
// 4文字目と5文字目
} else if (input.Substring(4, 1).Equals(input.Substring(5, 1))) {
Console.WriteLine("Yes");
return;
} else {
Console.WriteLine("No");
return;
}
}
}
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;
namespace CS.contests._160 {
public class Program {
public static void Main(string[] args) { new A().test(); }
}
}
public class A {
public void test() {
// スペース区切りの整数の入力
var input = CommonRead.ReadStr();
// 六文字以下は異なる
if (input.Length != 6) {
Console.WriteLine("No");
return;
}
// 3文字目と4文字目が異なる
if (!(input.Substring(2, 1).Equals(input.Substring(3, 1)))) {
Console.WriteLine("No");
return;
// 4文字目と5文字目が異なる
} else if (!(input.Substring(4, 1).Equals(input.Substring(5, 1)))) {
Console.WriteLine("No");
return;
} else {
Console.WriteLine("Yes");
return;
}
}
}
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();
}
}
|
[["+", 36, 36, 36, 36, 0, 208, 0, 209, 0, 256], ["+", 0, 208, 0, 209, 141, 232, 234, 232, 234, 22], ["+", 0, 208, 0, 209, 141, 232, 234, 232, 0, 131], ["+", 0, 208, 0, 209, 141, 232, 234, 232, 141, 22], ["+", 36, 36, 0, 208, 0, 209, 141, 232, 0, 131], ["+", 36, 36, 0, 208, 0, 209, 141, 232, 141, 22], ["+", 36, 36, 0, 208, 0, 209, 8, 201, 0, 45], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 241, 0, 111], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 24], ["+", 8, 196, 0, 57, 75, 57, 15, 241, 0, 111], ["+", 0, 195, 8, 196, 0, 57, 75, 57, 0, 25]]
| 8
| 565
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CF {
class Program {
static void Main(string[] args) {
// 22222
// 11111
// 11111
// var c = long.Parse(Console.ReadLine());
var d = Console.ReadLine();
if (d[2] == d[3] && d[4] == d[5])
Console.WriteLine("YES");
else
Console.WriteLine("NO");
var re = 0;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CF {
class Program {
static void Main(string[] args) {
// 22222
// 11111
// 11111
// var c = long.Parse(Console.ReadLine());
var d = Console.ReadLine();
if (d[2] == d[3] && d[4] == d[5])
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["-", 0, 195, 8, 196, 0, 57, 75, 1, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 93
| 9
|
using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int x = int.Parse(input[1]);
int y = int.Parse(input[2]);
int[] result = new int[n * 2];
int kouho1 = 0;
int kouho2 = 0;
int kouho3 = 0;
int kyori = 0;
for (int i = 1; i < n + 1; i++) {
// Console.WriteLine("test");
for (int j = i + 1; j < n + 1; j++) {
kyori = 0;
if (i == j || i >= j) {
continue;
} else {
// Console.WriteLine(i + "," + j);
kouho1 = j - i;
kouho2 = Math.Abs(x - i) + 1 + Math.Abs(j - y);
kouho3 = Math.Abs(y - i) + 1 + Math.Abs(j - x);
// Console.WriteLine(kouho1 + "," + kouho2 + "," + kouho3);
// Console.WriteLine("test5");
if (kouho1 > kouho2) {
kyori = kouho2;
// Console.WriteLine(kyori);
} else if (kouho1 < kouho2) {
kyori = kouho1;
}
/* else {
kyori = kouho3;
}
*/
if (kyori > kouho3) {
kyori = kouho3;
// Console.WriteLine(kyori);
}
// Console.WriteLine(kyori);
// Console.WriteLine("test6");
// Console.WriteLine(kyori);
// Console.WriteLine(n);
result[kyori] = result[kyori] + 1;
// Console.WriteLine("test3");
}
}
// Console.WriteLine("test4");
}
for (int k = 1; k < n; k++) {
Console.WriteLine(result[k]);
}
// Console.WriteLine(result);
}
static string equalCheck(string target1, string target2) {
if (target1 == target2) {
return "Yes";
} else {
return "No";
}
}
/*
static int NotEqualCheck(int target1,int target2,int shokiti){
if (target1 > target2){
return target2;
} else {
return shokiti;
}
}
*/
}
|
using System;
class Program {
static void Main() {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
int x = int.Parse(input[1]);
int y = int.Parse(input[2]);
int[] result = new int[n * 2];
int kouho1 = 0;
int kouho2 = 0;
int kouho3 = 0;
int kyori = 0;
for (int i = 1; i <= n - 1; i++) {
// Console.WriteLine("test");
for (int j = i + 1; j <= n; j++) {
kyori = 0;
if (i == j || i >= j) {
continue;
} else {
// Console.WriteLine(i + "," + j);
kouho1 = j - i;
kouho2 = Math.Abs(x - i) + 1 + Math.Abs(j - y);
kouho3 = Math.Abs(y - i) + 1 + Math.Abs(j - x);
// Console.WriteLine(kouho1 + "," + kouho2 + "," + kouho3);
// Console.WriteLine("test5");
if (kouho1 > kouho2) {
kyori = kouho2;
// Console.WriteLine(kyori);
} else {
kyori = kouho1;
}
/* else {
kyori = kouho3;
}
*/
if (kyori > kouho3) {
kyori = kouho3;
// Console.WriteLine(kyori);
}
// Console.WriteLine(kyori);
// Console.WriteLine("test6");
// Console.WriteLine(kyori);
// Console.WriteLine(n);
result[kyori] = result[kyori] + 1;
// Console.WriteLine("test3");
}
}
// Console.WriteLine("test4");
}
for (int k = 1; k < n; k++) {
Console.WriteLine(result[k]);
}
// Console.WriteLine(result);
}
static string equalCheck(string target1, string target2) {
if (target1 == target2) {
return "Yes";
} else {
return "No";
}
}
/*
static int NotEqualCheck(int target1,int target2,int shokiti){
if (target1 > target2){
return target2;
} else {
return shokiti;
}
}
*/
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 0, 57, 75, 196, 0, 57, 75, 57, 0, 121], ["-", 0, 57, 75, 196, 0, 57, 75, 57, 0, 24], ["-", 75, 196, 0, 57, 75, 57, 15, 16, 31, 22], ["-", 75, 196, 0, 57, 75, 57, 15, 16, 17, 18], ["-", 75, 196, 0, 57, 75, 57, 15, 16, 12, 22], ["-", 0, 57, 75, 196, 0, 57, 75, 57, 0, 25]]
| 8
| 336
| 14
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC160 {
class D {
static void Main(string[] args) {
var nxy = Console.ReadLine().Split().Select(long.Parse).ToArray();
var n = nxy[0];
var x = nxy[1] - 1;
var y = nxy[2] - 1;
var dist1 = new long[n, n];
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (i != j) {
dist1[i, j] =
Math.Min(Math.Abs(j - i), Math.Abs(x - i) + 1 + Math.Abs(j - y));
dist1[i, j] =
Math.Min(dist1[i, j], Math.Abs(y - j) + 1 + Math.Abs(j - x));
}
}
}
/*
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
Console.Write(dist1[i, j]);
}
Console.WriteLine();
}
*/
var res = new long[n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
res[dist1[i, j]]++;
}
}
for (int i = 1; i < n; i++) {
Console.WriteLine(res[i]);
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC160 {
class D {
static void Main(string[] args) {
var nxy = Console.ReadLine().Split().Select(long.Parse).ToArray();
var n = nxy[0];
var x = nxy[1] - 1;
var y = nxy[2] - 1;
var dist1 = new long[n, n];
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (i != j) {
dist1[i, j] =
Math.Min(Math.Abs(j - i), Math.Abs(x - i) + 1 + Math.Abs(j - y));
// dist1[i, j] = Math.Min(dist1[i, j], Math.Abs(y - i) + 1 +
// Math.Abs(j - x));
}
}
}
/*
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
Console.Write(dist1[i, j]);
}
Console.WriteLine();
}
*/
var res = new long[n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
res[dist1[i, j]]++;
}
}
for (int i = 1; i < n; i++) {
Console.WriteLine(res[i]);
}
}
}
}
|
[["-", 64, 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, 21], ["-", 0, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 12, 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, 21], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["-", 0, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["-", 0, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["-", 0, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["-", 0, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 0, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 12, 203], ["-", 12, 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], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35]]
| 8
| 296
| 39
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] NXY = Console.ReadLine().Split(' ');
int N = int.Parse(NXY[0]);
int X = int.Parse(NXY[1]);
int Y = int.Parse(NXY[2]);
int[] output = new int[N - 1];
int distance = 0;
for (int i = 0; i <= N - 1; i++) {
for (int j = i + 1; j <= N; j++) {
if (1 <= i && i <= X && 1 <= j && j <= X) {
distance = j - i;
} else if (1 <= i && i <= X && X < j && j < Y) {
distance = Math.Min(j - i, X + Y - i - j + 1);
} else if (1 <= i && i <= X && Y <= j && j <= N) {
distance = X - Y - i + j + 1;
} else if (X < i && i < Y && X < j && j < Y) {
distance = Math.Min(j - i, -X + Y + i - j + 1);
} else if (X < i && i < Y && Y <= j && j <= N) {
distance = Math.Min(j - i, -X - Y + i + j + 1);
} else {
distance = j - i;
}
output[distance - 1] += 1;
}
}
for (int i = 0; i < N - 1; i++) {
Console.WriteLine(output[i]);
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] NXY = Console.ReadLine().Split(' ');
int N = int.Parse(NXY[0]);
int X = int.Parse(NXY[1]);
int Y = int.Parse(NXY[2]);
int[] output = new int[N - 1];
int distance = 0;
for (int i = 1; i <= N - 1; i++) {
for (int j = i + 1; j <= N; j++) {
if (i <= X && j <= X) {
distance = j - i;
} else if (i <= X && X < j && j < Y) {
distance = Math.Min(j - i, X + Y - i - j + 1);
} else if (i <= X && Y <= j) {
distance = X - Y - i + j + 1;
} else if (X < i && i < Y && X < j && j < Y) {
distance = Math.Min(j - i, -X + Y + i - j + 1);
} else if (X < i && i < Y && Y <= j) {
distance = Math.Min(j - i, -X - Y + i + j + 1);
} else {
distance = j - i;
}
output[distance - 1] += 1;
}
}
for (int i = 0; i < N - 1; i++) {
Console.WriteLine(output[i]);
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 31, 203], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 19], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 98], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 203], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 75, 57, 15, 16, 31, 16, 31, 16, 17, 98], ["-", 75, 57, 15, 16, 31, 16, 12, 16, 12, 22], ["-", 0, 57, 75, 57, 75, 57, 15, 16, 17, 98], ["-", 75, 57, 75, 57, 15, 16, 12, 16, 17, 19], ["-", 75, 57, 75, 57, 15, 16, 12, 16, 12, 22], ["-", 75, 57, 75, 57, 75, 57, 15, 16, 17, 98], ["-", 75, 57, 75, 57, 15, 16, 12, 16, 31, 22]]
| 8
| 374
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderD {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int x = sc.NextInt();
int y = sc.NextInt();
int[] answers = new int[n];
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
int dist = 0;
if (j <= x || y <= i) {
dist = j - i;
} else if (i <= x && x <= j && j <= y) {
dist += x - i;
dist += Math.Min(1 + y - j, j - x);
} else if (x <= i && i <= y && y <= j) {
dist += Math.Min(1 + i - x, y - i);
dist += j - y;
} else if (i <= x && x <= y && y <= j) {
dist = x - i + 1 + j - y;
} else {
dist = j - i;
}
answers[dist]++;
}
}
for (int i = 1; i <= n - 1; i++) {
Console.WriteLine(answers[i]);
}
}
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 AtCoderD {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int x = sc.NextInt();
int y = sc.NextInt();
int[] answers = new int[n];
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
int dist = 0;
if (j <= x || y <= i) {
dist = j - i;
} else if (i <= x && x <= j && j <= y) {
dist += x - i;
dist += Math.Min(1 + y - j, j - x);
} else if (x <= i && i <= y && y <= j) {
dist += Math.Min(1 + i - x, y - i);
dist += j - y;
} else if (i <= x && x <= y && y <= j) {
dist = x - i + 1 + j - y;
} else {
dist += Math.Min(j - i, y - j + i - x + 1);
}
answers[dist]++;
}
}
for (int i = 1; i <= n - 1; i++) {
Console.WriteLine(answers[i]);
}
}
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();
}
}
|
[["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 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, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 581
| 17
|
using System; // Console, IComparable
using System.IO; // StreamWriter
using System.Linq; // Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; // List<T>
using System.Reflection; // PropertyInfo[], GetProperties[]
using static System.Console;
using static NNN.CInput;
namespace NNN {
public class CRun {
private static class gv {
public static int X { get; set; } = 0;
public static int Y { get; set; } = 0;
public static int A { get; set; } = 0;
public static int B { get; set; } = 0;
public static int C { get; set; } = 0;
public static int[] p, q, r;
}
public void build() {
string[] input;
input = _stringa;
var pi = typeof(gv).GetProperties();
for (int i = 0; i < 5; i++) {
pi[i].SetValue(typeof(gv), int.Parse(input[i]));
}
gv.p = _inta;
gv.q = _inta;
gv.r = _inta;
}
public void solve() {
StreamWriter stream_out = new StreamWriter(Console.OpenStandardOutput());
Array.Sort(gv.p, (x, y) => x > y ? 1 : 0);
Array.Sort(gv.q, (x, y) => x > y ? 1 : 0);
Array.Sort(gv.r, (x, y) => x > y ? 1 : 0);
var pCnt = 0;
var qCnt = 0;
var rCnt = 0;
var ans = 0L; // long
var cntDown = gv.X + gv.Y;
while (true) {
if (cntDown <= 0)
break;
var pNow = (pCnt < gv.p.Length ? gv.p[pCnt] : -1);
var qNow = (qCnt < gv.q.Length ? gv.q[qCnt] : -1);
var rNow = (rCnt < gv.r.Length ? gv.r[rCnt] : -1);
if (rNow >= pNow && rNow >= qNow) {
ans += rNow;
rCnt++;
} else if (pNow >= qNow) {
ans += pNow;
pCnt++;
} else {
ans += qNow;
qCnt++;
}
cntDown -= 1;
}
WriteLine(ans);
}
}
class Program {
static void Main() {
var run = new CRun();
run.build();
run.solve();
}
}
public static class CInput {
public static string _string {
get { return Console.ReadLine(); }
}
public static string[] _stringa {
get { return (Console.ReadLine().Split()); }
}
public static int _int {
get { return int.Parse(Console.ReadLine()); }
}
public static int[] _inta {
get {
return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
public static long _long {
get { return long.Parse(Console.ReadLine()); }
}
public static long[] _longa {
get {
return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
}
}
}
|
using System; // Console, IComparable
using System.IO; // StreamWriter
using System.Linq; // Select(), Where(), OrderBy(), Count()
using System.Collections.Generic; // List<T>
using System.Reflection; // PropertyInfo[], GetProperties[]
using static System.Console;
using static NNN.CInput;
namespace NNN {
public class CRun {
private static class gv {
public static int X { get; set; } = 0;
public static int Y { get; set; } = 0;
public static int A { get; set; } = 0;
public static int B { get; set; } = 0;
public static int C { get; set; } = 0;
public static int[] p, q, r;
}
public void build() {
string[] input;
input = _stringa;
var pi = typeof(gv).GetProperties();
for (int i = 0; i < 5; i++) {
pi[i].SetValue(typeof(gv), int.Parse(input[i]));
}
gv.p = _inta;
gv.q = _inta;
gv.r = _inta;
}
public void solve() {
StreamWriter stream_out = new StreamWriter(Console.OpenStandardOutput());
Array.Sort(gv.p, (x, y) => y - x);
Array.Sort(gv.q, (x, y) => y - x);
Array.Sort(gv.r, (x, y) => y - x);
var pCnt = 0;
var qCnt = 0;
var rCnt = 0;
var ans = 0L; // long
var cntDown = gv.X + gv.Y;
while (true) {
if (cntDown <= 0)
break;
var pNow = (pCnt < gv.X ? gv.p[pCnt] : -1);
var qNow = (qCnt < gv.Y ? gv.q[qCnt] : -1);
var rNow = (rCnt < gv.r.Length ? gv.r[rCnt] : -1);
// WriteLine($"{pCnt}, {qCnt}, {rCnt}");
// WriteLine($"{pNow}, {qNow}, {rNow}");
if (rNow >= pNow && rNow >= qNow) {
ans += rNow;
rCnt++;
} else if (pNow >= qNow) {
ans += pNow;
pCnt++;
} else {
ans += qNow;
qCnt++;
}
cntDown -= 1;
}
WriteLine(ans);
}
}
class Program {
static void Main() {
var run = new CRun();
run.build();
run.solve();
}
}
public static class CInput {
public static string _string {
get { return Console.ReadLine(); }
}
public static string[] _stringa {
get { return (Console.ReadLine().Split()); }
}
public static int _int {
get { return int.Parse(Console.ReadLine()); }
}
public static int[] _inta {
get {
return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
public static long _long {
get { return long.Parse(Console.ReadLine()); }
}
public static long[] _longa {
get {
return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
}
}
}
|
[["-", 0, 28, 0, 218, 8, 41, 15, 16, 31, 22], ["-", 0, 28, 0, 218, 8, 41, 15, 16, 17, 47], ["-", 3, 4, 0, 28, 0, 218, 8, 41, 0, 101], ["-", 3, 4, 0, 28, 0, 218, 8, 41, 64, 203], ["-", 3, 4, 0, 28, 0, 218, 8, 41, 0, 102], ["-", 3, 4, 0, 28, 0, 218, 8, 41, 75, 203], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 33], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 12, 22], ["-", 0, 41, 15, 16, 12, 214, 205, 214, 141, 22], ["-", 0, 23, 0, 41, 15, 16, 12, 214, 0, 131], ["-", 0, 23, 0, 41, 15, 16, 12, 214, 141, 22], ["+", 0, 23, 0, 41, 15, 16, 12, 214, 141, 22]]
| 8
| 671
| 32
|
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 Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
long[] n = longa();
long[] a = longa();
long[] b = longa();
long[] c = longa();
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
Array.Reverse(a);
Array.Reverse(b);
Array.Reverse(c);
long total = 0;
for (long i = 0; i < n[0]; i++) {
total += a[i];
}
for (long i = 0; i < n[1]; i++) {
total += b[i];
}
long an = n[0] - 1;
long bn = n[1] - 1;
for (long i = 0; i < n[4]; i++) {
if (an >= 0 && bn >= 0) {
if (a[an] < b[bn]) {
if (a[an] < c[i]) {
total += c[i] - a[an];
an--;
} else {
break;
}
}
if (a[an] >= b[bn]) {
if (b[bn] < c[i]) {
total += c[i] - b[bn];
bn--;
} else {
break;
}
}
} else {
if (an < 0 && bn >= 0) {
if (b[bn] < c[i]) {
total += c[i] - b[bn];
bn--;
} else {
break;
}
} else if (bn < 0 && an >= 0) {
if (a[an] < c[i]) {
total += c[i] - a[an];
an--;
} else {
break;
}
}
}
}
WriteLine(total);
}
static int binarysearchd(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] >= b) {
return 0;
} else if (a[leng - 1] < b) {
return leng;
} else {
if (a[max] < b) {
return max + 1;
}
return min + 1;
}
}
static int binarysearchu(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] > b) {
return leng;
} else if (a[leng - 1] <= b) {
return 0;
} else {
if (a[max] <= b) {
return leng - (max + 1);
}
return leng - (min + 1);
}
}
// 1からaまでの数字並べ替え全通り返すやつ
static List<string> permutation(int a) {
var list = new List<string>();
if (a == 1) {
list.Add("1");
return list;
} else {
foreach (var k in permutation(a - 1)) {
var ch = k.ToCharArray();
for (int i = 0; i <= ch.Length; i++) {
string intemp = "";
if (i == 0) {
intemp += a.ToString();
}
for (int j = 0; j < ch.Length; j++) {
intemp += ch[j].ToString();
if (i == j + 1) {
intemp += a.ToString();
}
}
list.Add(intemp);
}
}
}
return list;
}
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) {
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(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
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); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// var queue = new Queue<int>(); queue.Enqueue() queue.Dequeue()
// スタック -> 深さ優先 ???
// var stack = new Stack<int>(); stack.Push(hoge) stack.Pop() stackPeek()
// stack.Count
// if (list?.Count > 0) リストが空でもnullでもない
// ソート
// list.Sort(StringComparer.Ordinal); listの(辞書順?)ソート
// StringComparer.Ordinal とは
// Array.Sort(list1,list2);
// 出力
// foreach(var a int list){ WriteLine(a); } より
// WriteLine(string.Join("\n", list)); が速い
// var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
// Console.SetOut(sw);
// foreach(var k in list[num-1]){
// WriteLine(k);
// }
// Console.Out.Flush();
|
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 Hello {
static public int mod = 1000000007;
public static void Main() {
// 方針
//
long[] n = longa();
long[] a = longa();
long[] b = longa();
long[] c = longa();
Array.Sort(a);
Array.Sort(b);
Array.Sort(c);
Array.Reverse(a);
Array.Reverse(b);
Array.Reverse(c);
long total = 0;
for (long i = 0; i < n[0]; i++) {
total += a[i];
}
for (long i = 0; i < n[1]; i++) {
total += b[i];
}
long an = n[0] - 1;
long bn = n[1] - 1;
for (long i = 0; i < n[4]; i++) {
if (an >= 0 && bn >= 0) {
if (a[an] < b[bn]) {
if (a[an] < c[i]) {
total += c[i] - a[an];
an--;
} else {
break;
}
} else {
if (b[bn] < c[i]) {
total += c[i] - b[bn];
bn--;
} else {
break;
}
}
} else {
if (an < 0 && bn >= 0) {
if (b[bn] < c[i]) {
total += c[i] - b[bn];
bn--;
} else {
break;
}
} else if (bn < 0 && an >= 0) {
if (a[an] < c[i]) {
total += c[i] - a[an];
an--;
} else {
break;
}
}
}
}
WriteLine(total);
}
static int binarysearchd(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] >= b) {
return 0;
} else if (a[leng - 1] < b) {
return leng;
} else {
if (a[max] < b) {
return max + 1;
}
return min + 1;
}
}
static int binarysearchu(int[] a, int b) {
int leng = a.Length;
int min = 0;
int max = leng - 1;
while (max - min > 1) {
int mid = (min + max) / 2;
if (a[mid] < b) {
min = mid;
} else {
max = mid;
}
}
if (a[0] > b) {
return leng;
} else if (a[leng - 1] <= b) {
return 0;
} else {
if (a[max] <= b) {
return leng - (max + 1);
}
return leng - (min + 1);
}
}
// 1からaまでの数字並べ替え全通り返すやつ
static List<string> permutation(int a) {
var list = new List<string>();
if (a == 1) {
list.Add("1");
return list;
} else {
foreach (var k in permutation(a - 1)) {
var ch = k.ToCharArray();
for (int i = 0; i <= ch.Length; i++) {
string intemp = "";
if (i == 0) {
intemp += a.ToString();
}
for (int j = 0; j < ch.Length; j++) {
intemp += ch[j].ToString();
if (i == j + 1) {
intemp += a.ToString();
}
}
list.Add(intemp);
}
}
}
return list;
}
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) {
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(long a,long b,long m){var list = new List<int>();int
// temp = 1;long n2 = a;list.Add(1);int count = 1;while(temp <
// b){list.Add((int)n2);temp*=2;count++;n2 = n2*n2%m;}long ret = 1;while(b >
// 0){if(temp <= b){b -= temp;ret =
// ret*list[count]%1000000007;}count--;temp/=2;}return(int)ret;} 各種読取
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); }
}
//知見
// (string) hogestr -> (char[]) hoge
// char hoge = hogestr.ToCharArray();
// (char[]) hoge -> (string) hogestr
// string hoge = new string(hoge);
// Hashtable × Dictionary ○
// Dictionary hoge<string,int>
// hoge.ContainsKey(string) -> return boolean
// hoge[string] -> return int
// hoge[int] -> CE
// Dictionary hoge<int1,int2>
// hoge<int1,int2>: hoge[int1] -> return int2
// KeyValuePair<int,int> k <-> k.Key == int1 / k.Value == int2
// SortedDictionary() > SortedList() ???
// キュー -> 幅優先 ???
// var queue = new Queue<int>(); queue.Enqueue() queue.Dequeue()
// スタック -> 深さ優先 ???
// var stack = new Stack<int>(); stack.Push(hoge) stack.Pop() stackPeek()
// stack.Count
// if (list?.Count > 0) リストが空でもnullでもない
// ソート
// list.Sort(StringComparer.Ordinal); listの(辞書順?)ソート
// StringComparer.Ordinal とは
// Array.Sort(list1,list2);
// 出力
// foreach(var a int list){ WriteLine(a); } より
// WriteLine(string.Join("\n", list)); が速い
// var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
// Console.SetOut(sw);
// foreach(var k in list[num-1]){
// WriteLine(k);
// }
// Console.Out.Flush();
|
[["-", 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, 204, 205, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 20], ["-", 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, 22], ["-", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95]]
| 8
| 1,741
| 13
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { ABC160.F(); }
class ABC160 {
public static void A() {
var s = Read.Str();
Console.WriteLine(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}
public static void B() {
var X = Read.Long();
Console.WriteLine(X / 500 * 1000 + (X % 500) / 5 * 5);
}
public static void C() {
var K = Read.Long();
var N = Read.Int();
var A = Read.IntN();
var max = K + A[0] - A[N - 1];
for (int i = 0; i < N - 1; ++i) {
max = Math.Max(max, A[i + 1] - A[i]);
}
Console.WriteLine(K - max);
}
public static void D() {
var N = Read.Int();
var X = Read.Int();
var Y = Read.Int();
Dictionary<int, HashSet<int>> Adj = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
Adj.Add(i, new HashSet<int>());
}
for (int i = 1; i < N; ++i) {
Adj[i].Add(i + 1);
Adj[i + 1].Add(i);
}
Adj[X].Add(Y);
Adj[Y].Add(X);
int[] count = new int[N];
for (int v = 1; v <= N; ++v) {
int[] dist = Enumerable.Range(0, N + 1).Select(i => -1).ToArray();
Queue<int> queue = new Queue<int>();
dist[v] = 0;
queue.Enqueue(v);
while (queue.Count > 0) {
var w = queue.Dequeue();
foreach (var x in Adj[w]) {
if (dist[x] < 0) {
dist[x] = dist[w] + 1;
count[dist[x]]++;
queue.Enqueue(x);
}
}
}
}
for (int k = 1; k <= N - 1; ++k) {
Console.WriteLine(count[k] / 2);
}
}
public static void E() {
var X = Read.Int();
var Y = Read.Int();
var A = Read.Int();
var B = Read.Int();
var C = Read.Int();
var P = Read.LongN();
var Q = Read.LongN();
var R = Read.LongN();
List<Tuple<long, int>> list = new List<Tuple<long, int>>();
for (int i = 0; i < A; ++i) {
list.Add(new Tuple<long, int>(P[i], 0));
}
for (int i = 0; i < B; ++i) {
list.Add(new Tuple<long, int>(Q[i], 1));
}
for (int i = 0; i < C; ++i) {
list.Add(new Tuple<long, int>(R[i], 2));
}
list = list.OrderBy(x => -x.Item1).ToList();
long sum = 0;
int countX = 0;
int countY = 0;
int res = X + Y;
int idx = 0;
while (res > 0) {
var a = list[idx];
switch (a.Item2) {
case 0:
if (countX < X) {
sum += a.Item1;
countX++;
res--;
}
break;
case 1:
if (countY < Y) {
sum += a.Item1;
countY++;
res--;
}
break;
case 2:
sum += a.Item1;
res--;
break;
}
idx++;
}
Console.WriteLine(sum);
}
public static void F() {
var N = Read.Int();
var Adj = Read.AdjacencyList(N, N - 1);
var comb = Util.Combin(210000, Util.P);
MOD[] Ans = new MOD[N + 1];
MOD[] Count = new MOD[N + 1];
MOD[] ProdC = new MOD[N + 1];
var dist = Util.CalcDistance_OnTree(Adj, N, 1);
var order = Enumerable.Range(1, N).OrderBy(x => -dist[x]).ToArray();
var child = new int[N + 1];
foreach (var v in order) {
var parent = -1;
var children = new List<int>();
foreach (var c in Adj[v]) {
if (dist[c] < dist[v]) {
parent = c;
} else {
children.Add(c);
child[v] += child[c] + 1;
}
}
if (children.Count == 0) {
Count[v] = 1;
continue;
}
MOD prod = Count[children[0]];
var childTotal = child[children[0]] + 1;
ProdC[v] = 1;
for (int i = 1; i < children.Count; ++i) {
prod *= Count[children[i]];
var c = child[children[i]] + 1;
var com = comb(childTotal + c, c);
prod *= com;
ProdC[v] *= com;
childTotal += c;
}
Count[v] = prod;
}
Ans[1] = Count[1];
var queue = new Queue<int>();
queue.Enqueue(1);
while (queue.Count > 0) {
var v = queue.Dequeue();
var vProd = Ans[v] / ProdC[v];
foreach (var w in Adj[v]) {
if (Ans[w].V > 0) {
continue;
}
queue.Enqueue(w);
var PROD = vProd;
List<int> childCounts = new List<int>();
childCounts.Add(N - 1 - child[w]);
foreach (var wc in Adj[w]) {
if (dist[wc] > dist[w]) {
childCounts.Add(child[wc] + 1);
}
}
if (childCounts.Count == 1) {
Ans[w] = PROD;
} else {
MOD prodc = 1;
var total = childCounts[0];
for (int i = 1; i < childCounts.Count; ++i) {
var com = comb(total + childCounts[i], childCounts[i]);
PROD *= com;
prodc *= com;
total += childCounts[i];
}
Ans[w] = PROD / ProdC[w];
ProdC[w] = prodc;
}
}
}
for (int i = 1; i <= N; ++i) {
Console.WriteLine(Ans[i]);
}
}
}
class Util {
public static readonly long P = 1000000007;
public static int[] CalcDistance_OnTree(Dictionary<int, HashSet<int>> adj,
int N, int start) {
var dist = Enumerable.Range(0, N + 1).Select(i => -1).ToArray();
dist[start] = 0;
Queue<int> queue = new Queue<int>();
queue.Enqueue(start);
while (queue.Count > 0) {
var v = queue.Dequeue();
foreach (var w in adj[v]) {
if (dist[w] < 0) {
dist[w] = dist[v] + 1;
queue.Enqueue(w);
}
}
}
return dist;
}
public static long Power(long a, long n, long p) {
long res = 1;
long mult = a;
for (int i = 0; i < 40; ++i) {
if ((n & ((long)1 << i)) > 0) {
res = (res * mult) % p;
}
mult = (mult * mult) % p;
}
return res;
}
public static long Inverse(long a, long p) {
long b = p, c = 1, d = 0, e = 0, f = 0;
while (b != 0) {
e = a / b;
f = b;
b = a - e * b;
a = f;
f = d;
d = c - e * d;
c = f;
}
c %= p;
return c + (c < 0 ? p : 0);
}
public static long[] Facts(int n, long p) {
var facts = new long[n + 1];
facts[0] = 1;
for (int i = 1; i <= n; ++i) {
facts[i] = (i * facts[i - 1]) % p;
}
return facts;
}
public static Func<int, int, long> Combin(int n, long P) {
var fact = Facts(n, P);
var inv = fact.Select(x => Inverse(x, P)).ToArray();
return (N, M) => {
if (N < 0 || N < M || M < 0) {
return 0;
}
return (((fact[N] * inv[M]) % P) * inv[N - M]) % P;
};
}
public static Func<int, int, long> CombinLarge(int mMax, long p) {
var inv = Enumerable.Range(0, mMax + 1)
.Select(x => Util.Inverse(x, Util.P))
.ToArray();
return (n, m) => {
long mult = 1;
for (int i = 1; i <= m; ++i) {
mult = (((mult * (n + 1 - i)) % Util.P) * inv[i]) % Util.P;
}
return mult;
};
}
}
struct MOD {
public static long P = 1000000007;
public readonly long V;
public MOD(long a) { this.V = a; }
public static implicit operator MOD(long a) { return new MOD(a); }
public static MOD operator +(MOD a, MOD b) {
return new MOD((a.V + b.V) % P);
}
public static MOD operator -(MOD a, MOD b) {
return new MOD((a.V - b.V + P) % P);
}
public static MOD operator *(MOD a, MOD b) {
return new MOD((a.V * b.V) % P);
}
public static MOD operator /(MOD a, MOD b) {
return new MOD((a.V * b.Inverse().V) % P);
}
public MOD Inverse() { return Util.Inverse(V, P); }
public MOD Power(long n) { return Util.Power(V, n, P); }
public override string ToString() { return V.ToString(); }
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { ABC160.F(); }
class ABC160 {
public static void A() {
var s = Read.Str();
Console.WriteLine(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
}
public static void B() {
var X = Read.Long();
Console.WriteLine(X / 500 * 1000 + (X % 500) / 5 * 5);
}
public static void C() {
var K = Read.Long();
var N = Read.Int();
var A = Read.IntN();
var max = K + A[0] - A[N - 1];
for (int i = 0; i < N - 1; ++i) {
max = Math.Max(max, A[i + 1] - A[i]);
}
Console.WriteLine(K - max);
}
public static void D() {
var N = Read.Int();
var X = Read.Int();
var Y = Read.Int();
Dictionary<int, HashSet<int>> Adj = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
Adj.Add(i, new HashSet<int>());
}
for (int i = 1; i < N; ++i) {
Adj[i].Add(i + 1);
Adj[i + 1].Add(i);
}
Adj[X].Add(Y);
Adj[Y].Add(X);
int[] count = new int[N];
for (int v = 1; v <= N; ++v) {
int[] dist = Enumerable.Range(0, N + 1).Select(i => -1).ToArray();
Queue<int> queue = new Queue<int>();
dist[v] = 0;
queue.Enqueue(v);
while (queue.Count > 0) {
var w = queue.Dequeue();
foreach (var x in Adj[w]) {
if (dist[x] < 0) {
dist[x] = dist[w] + 1;
count[dist[x]]++;
queue.Enqueue(x);
}
}
}
}
for (int k = 1; k <= N - 1; ++k) {
Console.WriteLine(count[k] / 2);
}
}
public static void E() {
var X = Read.Int();
var Y = Read.Int();
var A = Read.Int();
var B = Read.Int();
var C = Read.Int();
var P = Read.LongN();
var Q = Read.LongN();
var R = Read.LongN();
List<Tuple<long, int>> list = new List<Tuple<long, int>>();
for (int i = 0; i < A; ++i) {
list.Add(new Tuple<long, int>(P[i], 0));
}
for (int i = 0; i < B; ++i) {
list.Add(new Tuple<long, int>(Q[i], 1));
}
for (int i = 0; i < C; ++i) {
list.Add(new Tuple<long, int>(R[i], 2));
}
list = list.OrderBy(x => -x.Item1).ToList();
long sum = 0;
int countX = 0;
int countY = 0;
int res = X + Y;
int idx = 0;
while (res > 0) {
var a = list[idx];
switch (a.Item2) {
case 0:
if (countX < X) {
sum += a.Item1;
countX++;
res--;
}
break;
case 1:
if (countY < Y) {
sum += a.Item1;
countY++;
res--;
}
break;
case 2:
sum += a.Item1;
res--;
break;
}
idx++;
}
Console.WriteLine(sum);
}
public static void F() {
var N = Read.Int();
var Adj = Read.AdjacencyList(N, N - 1);
var comb = Util.Combin(210000, Util.P);
MOD[] Ans = new MOD[N + 1];
MOD[] Count = new MOD[N + 1];
MOD[] ProdC = new MOD[N + 1];
var dist = Util.CalcDistance_OnTree(Adj, N, 1);
var order = Enumerable.Range(1, N).OrderBy(x => -dist[x]).ToArray();
var child = new int[N + 1];
foreach (var v in order) {
var parent = -1;
var children = new List<int>();
foreach (var c in Adj[v]) {
if (dist[c] < dist[v]) {
parent = c;
} else {
children.Add(c);
child[v] += child[c] + 1;
}
}
if (children.Count == 0) {
Count[v] = 1;
continue;
}
MOD prod = Count[children[0]];
var childTotal = child[children[0]] + 1;
ProdC[v] = 1;
for (int i = 1; i < children.Count; ++i) {
prod *= Count[children[i]];
var c = child[children[i]] + 1;
var com = comb(childTotal + c, c);
prod *= com;
ProdC[v] *= com;
childTotal += c;
}
Count[v] = prod;
}
Ans[1] = Count[1];
var queue = new Queue<int>();
queue.Enqueue(1);
while (queue.Count > 0) {
var v = queue.Dequeue();
// var vProd = Ans[v] / ProdC[v];
foreach (var w in Adj[v]) {
var vProd = Ans[v] / comb(N - 1, child[w] + 1);
if (Ans[w].V > 0) {
continue;
}
queue.Enqueue(w);
var PROD = vProd;
List<int> childCounts = new List<int>();
childCounts.Add(N - 1 - child[w]);
foreach (var wc in Adj[w]) {
if (dist[wc] > dist[w]) {
childCounts.Add(child[wc] + 1);
}
}
if (childCounts.Count == 1) {
Ans[w] = PROD;
} else {
MOD prodc = 1;
var total = childCounts[0];
for (int i = 1; i < childCounts.Count; ++i) {
var com = comb(total + childCounts[i], childCounts[i]);
PROD *= com;
prodc *= com;
total += childCounts[i];
}
Ans[w] = PROD / ProdC[w];
ProdC[w] = prodc;
}
}
}
for (int i = 1; i <= N; ++i) {
Console.WriteLine(Ans[i]);
}
}
}
class Util {
public static readonly long P = 1000000007;
public static int[] CalcDistance_OnTree(Dictionary<int, HashSet<int>> adj,
int N, int start) {
var dist = Enumerable.Range(0, N + 1).Select(i => -1).ToArray();
dist[start] = 0;
Queue<int> queue = new Queue<int>();
queue.Enqueue(start);
while (queue.Count > 0) {
var v = queue.Dequeue();
foreach (var w in adj[v]) {
if (dist[w] < 0) {
dist[w] = dist[v] + 1;
queue.Enqueue(w);
}
}
}
return dist;
}
public static long Power(long a, long n, long p) {
long res = 1;
long mult = a;
for (int i = 0; i < 40; ++i) {
if ((n & ((long)1 << i)) > 0) {
res = (res * mult) % p;
}
mult = (mult * mult) % p;
}
return res;
}
public static long Inverse(long a, long p) {
long b = p, c = 1, d = 0, e = 0, f = 0;
while (b != 0) {
e = a / b;
f = b;
b = a - e * b;
a = f;
f = d;
d = c - e * d;
c = f;
}
c %= p;
return c + (c < 0 ? p : 0);
}
public static long[] Facts(int n, long p) {
var facts = new long[n + 1];
facts[0] = 1;
for (int i = 1; i <= n; ++i) {
facts[i] = (i * facts[i - 1]) % p;
}
return facts;
}
public static Func<int, int, long> Combin(int n, long P) {
var fact = Facts(n, P);
var inv = fact.Select(x => Inverse(x, P)).ToArray();
return (N, M) => {
if (N < 0 || N < M || M < 0) {
return 0;
}
return (((fact[N] * inv[M]) % P) * inv[N - M]) % P;
};
}
public static Func<int, int, long> CombinLarge(int mMax, long p) {
var inv = Enumerable.Range(0, mMax + 1)
.Select(x => Util.Inverse(x, Util.P))
.ToArray();
return (n, m) => {
long mult = 1;
for (int i = 1; i <= m; ++i) {
mult = (((mult * (n + 1 - i)) % Util.P) * inv[i]) % Util.P;
}
return mult;
};
}
}
struct MOD {
public static long P = 1000000007;
public readonly long V;
public MOD(long a) { this.V = a; }
public static implicit operator MOD(long a) { return new MOD(a); }
public static MOD operator +(MOD a, MOD b) {
return new MOD((a.V + b.V) % P);
}
public static MOD operator -(MOD a, MOD b) {
return new MOD((a.V - b.V + P) % P);
}
public static MOD operator *(MOD a, MOD b) {
return new MOD((a.V * b.V) % P);
}
public static MOD operator /(MOD a, MOD b) {
return new MOD((a.V * b.Inverse().V) % P);
}
public MOD Inverse() { return Util.Inverse(V, P); }
public MOD Power(long n) { return Util.Power(V, n, P); }
public override string ToString() { return V.ToString(); }
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1]);
dict[ab[1]].Add(ab[0]);
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
[["+", 8, 196, 0, 52, 8, 196, 0, 210, 0, 266], ["+", 8, 196, 0, 52, 8, 196, 0, 210, 0, 24], ["+", 0, 52, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 8, 196, 0, 52, 8, 196, 0, 210, 31, 22], ["+", 8, 196, 0, 52, 8, 196, 0, 210, 0, 267], ["+", 0, 52, 8, 196, 0, 210, 12, 204, 205, 22], ["+", 8, 196, 0, 210, 12, 204, 206, 207, 0, 70], ["+", 0, 210, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 8, 196, 0, 210, 12, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 52, 8, 196, 0, 210, 0, 25], ["+", 0, 52, 8, 196, 0, 210, 8, 196, 0, 45], ["-", 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, 22], ["-", 0, 212, 0, 16, 12, 204, 206, 207, 0, 73], ["-", 8, 196, 0, 52, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 52, 8, 196, 0, 210, 0, 266], ["+", 0, 200, 0, 212, 0, 16, 12, 213, 63, 22], ["-", 0, 52, 8, 196, 0, 210, 39, 216, 0, 217], ["-", 8, 196, 0, 52, 8, 196, 0, 210, 31, 22], ["-", 8, 196, 0, 52, 8, 196, 0, 210, 0, 267], ["-", 0, 52, 8, 196, 0, 210, 12, 204, 205, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 212, 0, 16, 12, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 16, 31, 204, 205, 22], ["-", 0, 210, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 52, 8, 196, 0, 210, 8, 196, 0, 45], ["+", 8, 196, 0, 210, 8, 196, 0, 197, 0, 35]]
| 8
| 3,442
| 33
|
using System;
namespace ConsoleApp2 {
public class Program {
public static void Main(string[] args) {
int n, m;
var buf = Console.ReadLine().Split(' ');
n = int.Parse(buf[0]);
m = int.Parse(buf[1]);
int count = 0;
count += n * (n - 1) / 2;
count += m * (m - 1) / 2;
Console.WriteLine((n + m) * (n + m - 1) / (1 * 2));
Console.WriteLine(count);
}
}
}
|
using System;
namespace ConsoleApp2 {
public class Program {
public static void Main(string[] args) {
int n, m;
var buf = Console.ReadLine().Split(' ');
n = int.Parse(buf[0]);
m = int.Parse(buf[1]);
int count = 0;
count += n * (n - 1) / 2;
count += m * (m - 1) / 2;
Console.WriteLine(count);
}
}
}
|
[["-", 0, 28, 0, 16, 31, 16, 31, 23, 0, 24], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["-", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 0, 28, 0, 16, 31, 16, 12, 23, 0, 24], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 31, 22], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 17, 72], ["-", 31, 16, 12, 23, 0, 16, 31, 16, 12, 22], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["-", 0, 16, 31, 16, 12, 23, 0, 16, 12, 203], ["-", 0, 28, 0, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 31, 203], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 17, 48], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 12, 203], ["-", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 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]]
| 8
| 130
| 25
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _159_A {
class Program {
static void Main(string[] args) {
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(((a[0] <= 1 ? 0 : a[0] * (a[0] - 1) / 2) +
(a[1] <= 1 ? 1 : a[1] * (a[1] - 1) / 2))
.ToString());
}
}
}
|
using System;
using System.Linq;
namespace _159_A {
internal class Program {
private static void Main(string[] args) {
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(((a[0] <= 1 ? 0 : a[0] * (a[0] - 1) / 2) +
(a[1] <= 1 ? 0 : a[1] * (a[1] - 1) / 2))
.ToString());
}
}
}
|
[["-", 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, 208, 0, 231, 141, 232, 234, 232, 234, 22], ["-", 0, 208, 0, 231, 141, 232, 234, 232, 0, 131], ["+", 0, 209, 8, 201, 0, 235, 0, 251, 0, 305], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 261], ["-", 205, 23, 0, 16, 12, 23, 0, 41, 64, 203], ["+", 205, 23, 0, 16, 12, 23, 0, 41, 64, 203]]
| 8
| 135
| 23
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
int ans = 0;
if (N != 0 && M != 0)
ans = N * (N - 1) / 2 + M * (M - 1) / 2;
Console.WriteLine(ans);
}
}
}
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split();
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
int ans = 0;
if (N != 0)
ans += N * (N - 1) / 2;
if (M != 0)
ans += M * (M - 1) / 2;
Console.WriteLine(ans);
}
}
}
|
[["-", 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, 79], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 107], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 195, 8, 196, 0, 57, 64, 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, 79], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22]]
| 8
| 105
| 16
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
var inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = inputNum[0];
var M = inputNum[1];
var answer = 0;
if (M >= 2) {
answer += M;
}
if (N >= 2) {
answer += (N * (N - 1)) / 2;
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
static void Main(string[] args) {
var inputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = inputNum[0];
var M = inputNum[1];
var answer = 0;
if (M >= 2) {
answer += (M * (M - 1)) / 2;
}
if (N >= 2) {
answer += (N * (N - 1)) / 2;
}
Console.WriteLine(answer);
}
}
}
|
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 17, 33], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
| 8
| 128
| 10
|
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
hoge();
// System.Console.ReadLine();
}
public static void hoge() {
var vars =
System.Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray();
ulong n = vars[0];
ulong m = vars[1];
ulong gu = 0;
ulong ki = 0;
if (n > 2) {
gu = n * (n - 1) / 2;
}
if (m > 2) {
ki = m * (m - 1) / 2;
}
System.Console.WriteLine(gu + ki);
}
}
|
using System.Collections.Generic;
using System.Linq;
public class Hello {
public static void Main() {
hoge();
System.Console.ReadLine();
}
public static void hoge() {
var vars =
System.Console.ReadLine().Split(' ').Select(ulong.Parse).ToArray();
ulong n = vars[0];
ulong m = vars[1];
ulong gu = 0;
ulong ki = 0;
if (n >= 2) {
gu = n * (n - 1) / 2;
}
if (m >= 2) {
ki = m * (m - 1) / 2;
}
System.Console.WriteLine(gu + ki);
}
}
|
[["+", 0, 1, 0, 213, 63, 214, 205, 214, 205, 22], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 0, 131], ["+", 0, 1, 0, 213, 63, 214, 205, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 144
| 12
|
using System;
using System.Linq;
class B {
static void Main() {
var s = Console.ReadLine();
var s1 = s.Remove(s.Length / 2);
var s2 = s.Substring(s1.Length + 1);
var s1r = new string(s1.Reverse().ToArray());
Console.WriteLine(s1r == s2 ? "Yes" : "No");
}
}
|
using System;
using System.Linq;
class B {
static void Main() {
var s = Console.ReadLine();
var s1 = s.Remove(s.Length / 2);
var s2 = s.Substring(s1.Length + 1);
var s1r = string.Join("", s1.Reverse());
Console.WriteLine(s1 == s2 && s1 == s1r ? "Yes" : "No");
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 0, 131], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 98], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 31, 22], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 17, 60], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 12, 22]]
| 8
| 90
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionJ {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 文字列の入力
string str_S = Console.ReadLine();
var num_Length = str_S.Length;
var num_End = (num_Length - 1) / 2;
var num_Start = (num_Length + 3) / 2;
var str_New01 = str_S.Substring(0, num_End);
var str_New02 = str_S.Substring(num_Start - 1);
var str_Rev01 = new string(str_New01.Reverse().ToArray());
var str_Rev02 = new string(str_New02.Reverse().ToArray());
if (str_New01 == str_Rev01 & str_New02 == str_Rev02) {
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 QuestionJ {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 文字列の入力
string str_S = Console.ReadLine();
var num_Length = str_S.Length;
var num_End = (num_Length - 1) / 2;
var num_Start = (num_Length + 3) / 2;
var str_New01 = str_S.Substring(0, num_End);
var str_New02 = str_S.Substring(num_Start - 1);
if (str_New01 == str_New02)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
Console.Out.Flush();
}
}
}
|
[["-", 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, 230, 0, 228], ["-", 0, 198, 0, 200, 0, 212, 0, 230, 39, 199], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 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], ["-", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 67], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 214
| 40
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using static Input;
using static Util;
class Program {
static string S;
static void INPUT() { S = NextString(); }
static void OUT() {
var len = S.Length;
var b = true;
for (var i = 0; i < (len - 1) / 2; i++) {
if (S[i] != S[(len - 1) / 2 - 1 - i]) {
b = false;
break;
}
}
if (S.Substring(0, (len - 1) / 2) == S.Substring((len - 1) / 2))
b = false;
Console.WriteLine(b ? "Yes" : "No");
}
static void Main(string[] args) {
#if DEBUG
TESTINPUT();
// INPUT();
#else
INPUT();
#endif
OUT();
}
static void TESTINPUT() {}
}
public class Input {
public const long MOD = 1000000007;
public const int INF = 1000000007;
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
class Util {}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using static Input;
using static Util;
class Program {
static string S;
static void INPUT() { S = NextString(); }
static void OUT() {
var len = S.Length;
var b = true;
for (var i = 0; i < (len - 1) / 2; i++) {
if (S[i] != S[(len - 1) / 2 - 1 - i]) {
b = false;
break;
}
}
if (S.Substring(0, (len - 1) / 2) != S.Substring((len + 2) / 2))
b = false;
Console.WriteLine(b ? "Yes" : "No");
}
static void Main(string[] args) {
#if DEBUG
TESTINPUT();
// INPUT();
#else
INPUT();
#endif
OUT();
}
static void TESTINPUT() { S = "akasaka"; }
}
public class Input {
public const long MOD = 1000000007;
public const int INF = 1000000007;
private static Queue<string> q = new Queue<string>();
private static void Confirm() {
if (q.Count == 0)
foreach (var s in Console.ReadLine().Split(' '))
q.Enqueue(s);
}
public static int NextInt() {
Confirm();
return int.Parse(q.Dequeue());
}
public static long NextLong() {
Confirm();
return long.Parse(q.Dequeue());
}
public static string NextString() {
Confirm();
return q.Dequeue();
}
public static double NextDouble() {
Confirm();
return double.Parse(q.Dequeue());
}
public static int[] LineInt() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long[] LineLong() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static string[] LineString() {
return Console.ReadLine().Split(' ').ToArray();
}
public static double[] LineDouble() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
class Util {}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 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, 11, 12, 5, 0, 62], ["+", 8, 196, 0, 1, 0, 11, 12, 5, 0, 222], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 523
| 12
|
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;
class MainClass {
public static void Main(string[] args) {
var Nums = LnStrs();
Console.WriteLine(Nums[1] + " " + Nums[2] + " " + Nums[0]);
}
public static long Gcd(long a, long b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int Gcd(int a, int b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
public static long[] LnLngs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new long[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = long.Parse(vs[i]);
return ins;
}
public static long LnLng() {
var vs = Console.ReadLine().Trim();
return long.Parse(vs);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
}
|
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;
class MainClass {
public static void Main(string[] args) {
var Nums = LnStrs();
Console.WriteLine(Nums[2] + " " + Nums[0] + " " + Nums[1]);
}
public static long Gcd(long a, long b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int Gcd(int a, int b) {
if (a > b) {
var r = a % b;
if (r == 0)
return b;
else
return Gcd(b, r);
} else {
var r = b % a;
if (r == 0)
return a;
else
return Gcd(a, r);
}
}
public static int[] LnInts() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new int[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = int.Parse(vs[i]);
return ins;
}
public static int LnInt() {
var vs = Console.ReadLine().Trim();
return int.Parse(vs);
}
public static long[] LnLngs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var ins = new long[vs.Length];
for (int i = 0; i < vs.Length; i++)
ins[i] = long.Parse(vs[i]);
return ins;
}
public static long LnLng() {
var vs = Console.ReadLine().Trim();
return long.Parse(vs);
}
public static string[] LnStrs() {
var vs = Console.ReadLine().Trim().Split(
new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return vs;
}
public static string LnStr() {
var vs = Console.ReadLine().Trim();
return vs;
}
}
|
[["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 517
| 6
|
using System;
namespace atcoder {
class Program {
static void Main(string[] args) {
string[] In = Console.ReadLine().Split(' ');
Console.WriteLine(In[2] + In[0] + In[1]);
}
}
}
|
using System;
namespace atcoder {
class Program {
static void Main(string[] args) {
string[] In = Console.ReadLine().Split(' ');
Console.WriteLine(In[2] + " " + In[0] + " " + In[1]);
}
}
}
|
[["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 31, 16, 31, 16, 31, 16, 12, 5, 0, 222], ["+", 0, 28, 0, 16, 31, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222]]
| 8
| 60
| 8
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
#region library
static bool debug = false;
static int n = 0;
static int m = 0;
static int r = 0;
static int c = 0;
static int x = 0;
static int y = 0;
static string s = "";
static string[] ss;
static long sum = 0;
static long cnt = 0;
static long max = -1;
static long min = 2147483647;
static bool flg = false;
static bool flg2 = false;
static string alpha = "abcdefghijklmnopqrstuvwxyz";
static long mod = 1000000007;
static long[] arr;
static char[,] map;
static long[,] imap;
public class Input {
static readonly char[] separator = { ' ', '\r', '\n' };
readonly StreamReader sr;
readonly Queue<string> queue;
public Input(string path = "") {
queue = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
queue.Enqueue(elem);
}
return true;
}
public bool Any() { return queue.Any() || Read(); }
bool Read() {
if (!SetText(sr.ReadLine()))
return false;
if (!queue.Any())
return Read();
return queue.Any();
}
public string Next() {
if (!queue.Any() && !Read()) {
return "";
}
return queue.Dequeue();
}
bool Accumulate(int n) {
while (queue.Count() < n) {
if (!Read())
return false;
}
return true;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!Accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(queue.Dequeue()), offset);
return a;
}
public string[] Next(int n) { return NextT(n, "", x => x, (x, y) => x); }
public int[] NextInt(int n, int offset = 0) {
return NextT(n, offset, int.Parse, (x, y) => x + y);
}
public long[] NextLong(int n, long offset = 0) {
return NextT(n, offset, long.Parse, (x, y) => x + y);
}
public double[] NextDouble(int n, double offset = 0.0) {
return NextT(n, offset, double.Parse, (x, y) => x + y);
}
}
static Input input;
static int Int() { return input.NextInt(); }
static long Long() { return input.NextLong(); }
static double Double() { return input.NextDouble(); }
static string Text() { return input.Next(); }
static void wl(object obj = null) { Console.WriteLine(obj); }
static void w(object obj) { Console.Write(obj); }
static void Yes() { wl("YES"); }
static void No() { wl("NO"); }
static void Sum() { wl(sum); }
static void Cnt() { wl(cnt); }
static void SetArray(long num = -1) {
if (n == 0) {
n = Int();
}
arr = new long[n];
for (int i = 0; i < n; i++) {
if (num == -1)
arr[i] = Int();
else
arr[i] = num;
}
}
static void ShowArray() {
for (int i = 0; i < arr.Length; i++) {
if (i > 0)
w(" ");
w(arr[i]);
}
wl();
}
static void SetMap(char def = '@') {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
map = new char[r, c];
for (int i = 0; i < r; i++) {
if (def == '@')
s = Text();
for (int j = 0; j < c; j++) {
map[i, j] = (def == '@') ? s[j] : def;
}
}
}
static void SetIMap(long def = -1) {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
imap = new long[r, c];
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
imap[i, j] = (def == -1) ? Int() : def;
}
}
}
static void ShowMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(map[i, j]);
}
wl();
}
}
static void ShowIMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(imap[i, j]);
}
wl();
}
}
#endregion
#region main
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
input = new Input();
try {
Solve();
} catch (Exception ex) {
if (debug)
wl(ex); // chcp 65001
else
throw ex;
}
Console.Out.Flush();
}
public static void Solve() {
n = Int();
int m = Int();
SetArray();
Array.Sort(arr);
Array.Reverse(arr);
for (int i = 0; i < n; i++) {
sum += arr[i];
}
flg = true;
for (int i = 0; i < m; i++) {
if (arr[i] < sum / (4 * m)) {
flg = false;
break;
}
}
if (flg)
wl("Yes");
else
wl("No");
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
#region library
static bool debug = false;
static int n = 0;
static int m = 0;
static int r = 0;
static int c = 0;
static int x = 0;
static int y = 0;
static string s = "";
static string[] ss;
static long sum = 0;
static long cnt = 0;
static long max = -1;
static long min = 2147483647;
static bool flg = false;
static bool flg2 = false;
static string alpha = "abcdefghijklmnopqrstuvwxyz";
static long mod = 1000000007;
static long[] arr;
static char[,] map;
static long[,] imap;
public class Input {
static readonly char[] separator = { ' ', '\r', '\n' };
readonly StreamReader sr;
readonly Queue<string> queue;
public Input(string path = "") {
queue = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
queue.Enqueue(elem);
}
return true;
}
public bool Any() { return queue.Any() || Read(); }
bool Read() {
if (!SetText(sr.ReadLine()))
return false;
if (!queue.Any())
return Read();
return queue.Any();
}
public string Next() {
if (!queue.Any() && !Read()) {
return "";
}
return queue.Dequeue();
}
bool Accumulate(int n) {
while (queue.Count() < n) {
if (!Read())
return false;
}
return true;
}
public int NextInt() { return int.Parse(Next()); }
public long NextLong() { return long.Parse(Next()); }
public double NextDouble() { return double.Parse(Next()); }
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!Accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(queue.Dequeue()), offset);
return a;
}
public string[] Next(int n) { return NextT(n, "", x => x, (x, y) => x); }
public int[] NextInt(int n, int offset = 0) {
return NextT(n, offset, int.Parse, (x, y) => x + y);
}
public long[] NextLong(int n, long offset = 0) {
return NextT(n, offset, long.Parse, (x, y) => x + y);
}
public double[] NextDouble(int n, double offset = 0.0) {
return NextT(n, offset, double.Parse, (x, y) => x + y);
}
}
static Input input;
static int Int() { return input.NextInt(); }
static long Long() { return input.NextLong(); }
static double Double() { return input.NextDouble(); }
static string Text() { return input.Next(); }
static void wl(object obj = null) { Console.WriteLine(obj); }
static void w(object obj) { Console.Write(obj); }
static void Yes() { wl("YES"); }
static void No() { wl("NO"); }
static void Sum() { wl(sum); }
static void Cnt() { wl(cnt); }
static void SetArray(long num = -1) {
if (n == 0) {
n = Int();
}
arr = new long[n];
for (int i = 0; i < n; i++) {
if (num == -1)
arr[i] = Int();
else
arr[i] = num;
}
}
static void ShowArray() {
for (int i = 0; i < arr.Length; i++) {
if (i > 0)
w(" ");
w(arr[i]);
}
wl();
}
static void SetMap(char def = '@') {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
map = new char[r, c];
for (int i = 0; i < r; i++) {
if (def == '@')
s = Text();
for (int j = 0; j < c; j++) {
map[i, j] = (def == '@') ? s[j] : def;
}
}
}
static void SetIMap(long def = -1) {
if (r == 0 && c == 0) {
r = Int();
c = Int();
}
imap = new long[r, c];
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
imap[i, j] = (def == -1) ? Int() : def;
}
}
}
static void ShowMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(map[i, j]);
}
wl();
}
}
static void ShowIMap() {
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
w(imap[i, j]);
}
wl();
}
}
#endregion
#region main
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
input = new Input();
try {
Solve();
} catch (Exception ex) {
if (debug)
wl(ex); // chcp 65001
else
throw ex;
}
Console.Out.Flush();
}
public static void Solve() {
n = Int();
int m = Int();
SetArray();
Array.Sort(arr);
Array.Reverse(arr);
for (int i = 0; i < n; i++) {
sum += arr[i];
}
flg = true;
for (int i = 0; i < m; i++) {
if ((double)arr[i] < (double)sum / (double)(4 * m)) {
flg = false;
break;
}
}
if (flg)
wl("Yes");
else
wl("No");
}
#endregion
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 74, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 39, 199], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 0, 25], ["+", 0, 57, 15, 16, 12, 16, 31, 74, 0, 24], ["+", 0, 57, 15, 16, 12, 16, 31, 74, 39, 199], ["+", 0, 57, 15, 16, 12, 16, 31, 74, 0, 25], ["+", 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, 0, 25]]
| 8
| 1,534
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
public static class Program {
public static void Main(string[] args) {
var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
var vals = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
vals.Sort();
vals.Reverse();
var min = (double)vals.Sum() / (4.0 * nm[1]);
if (vals.Take(nm[1]).Count(x => x < min) > 0)
Console.Write("Yes");
else
Console.Write("No");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
public static class Program {
public static void Main(string[] args) {
var nm = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
var vals = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
vals.Sort();
vals.Reverse();
var min = (double)vals.Sum() / (4.0 * nm[1]);
if (vals.Take(nm[1]).Count(x => x < min) > 0)
Console.Write("No");
else
Console.Write("Yes");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 166
| 4
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC161B {
class Program {
static void Main(string[] args) {
var N = RInt;
var M = RInt;
var A = RInts;
int meyasu = A.Sum() / (4 * M);
int count = A.Count(x => x > meyasu);
if (count >= M)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
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();
}
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 ABC161B {
class Program {
static void Main(string[] args) {
var N = RInt;
var M = RInt;
var A = RInts;
int meyasu = A.Sum() / (4 * M);
if (A.Sum() % (4 * M) == 0)
meyasu--;
int count = A.Count(x => x > meyasu);
if (count >= M)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
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();
}
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, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 31, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 31, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 16, 31, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 0, 57, 15, 16, 31, 16, 12, 23, 0, 24], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 31, 203], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 68], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 728
| 19
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Test {
public static void Main() {
//入力
String[] R = Console.ReadLine().Split();
int N = int.Parse(R[0]);
int M = int.Parse(R[1]);
String[] _A = Console.ReadLine().Split();
int[] A = _A.Select(s => int.Parse(s)).ToArray();
//総得票数
int S = A.Sum();
int count = 0;
//主処理
foreach (int i in A) {
if (i >= (S % (4 * M))) {
++count;
}
}
//出力
if (count >= M) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Test {
public static void Main() {
//入力
String[] R = Console.ReadLine().Split();
int N = int.Parse(R[0]);
double M = int.Parse(R[1]);
//条件
double M_ = 1 / (4 * M);
String[] _A = Console.ReadLine().Split();
int[] A = _A.Select(s => int.Parse(s)).ToArray();
//総得票数
int S = A.Sum();
double S_ = S * M_;
int count = 0;
//主処理
foreach (int i in A) {
if (i >= S_) {
++count;
}
}
//出力
if (count >= M) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 31, 203], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 17, 48], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 23, 0, 24], ["-", 0, 57, 15, 16, 12, 23, 0, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 23, 0, 16, 17, 109], ["-", 15, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 31, 203], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 17, 48], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 12, 22], ["-", 15, 16, 12, 23, 0, 16, 12, 23, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 12, 23, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 187
| 30
|
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
class Program {
static void Main(string[] args) {
int[] intArray =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int N = intArray[0];
int M = intArray[1];
List<int> A = new List<int>(
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
A.Sort();
A.Reverse();
decimal line = A.Sum() / (4 * M);
Boolean ok = true;
for (int i = 0; i < M; i++) {
if (A[i] <= line) {
ok = false;
break;
}
}
if (ok)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
// string s = Console.ReadLine();
// int[] intArray = Console.ReadLine().Split(' ').Select(i =>
// int.Parse(i)).ToArray(); int H = intArray[0]; int W = intArray[1]; int N =
// int.Parse(Console.ReadLine()); List<int> A = new
// List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
// Boolean ok = false;
// Console.WriteLine(ans);
// Console.WriteLine("Yes");
// Console.WriteLine("No");
// Console.ReadKey();
// string[] strArray = Console.ReadLine().Split(' ').ToArray();
// string S = strArray[0];
// string T = strArray[1];
|
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
class Program {
static void Main(string[] args) {
int[] intArray =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int N = intArray[0];
int M = intArray[1];
List<int> A = new List<int>(
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
A.Sort();
A.Reverse();
decimal line = (decimal)A.Sum() / (decimal)(4 * M);
Boolean ok = true;
for (int i = 0; i < M; i++) {
if (A[i] < line) {
ok = false;
break;
}
}
if (ok)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
// string s = Console.ReadLine();
// int[] intArray = Console.ReadLine().Split(' ').Select(i =>
// int.Parse(i)).ToArray(); int H = intArray[0]; int W = intArray[1]; int N =
// int.Parse(Console.ReadLine()); List<int> A = new
// List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
// Boolean ok = false;
// Console.WriteLine(ans);
// Console.WriteLine("Yes");
// Console.WriteLine("No");
// Console.ReadKey();
// string[] strArray = Console.ReadLine().Split(' ').ToArray();
// string S = strArray[0];
// string T = strArray[1];
|
[["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18]]
| 8
| 242
| 8
|
using System;
using System.Linq;
namespace AtCoder20200404 {
class Program {
static void Main(string[] args) {
String[] inputs = Console.ReadLine().Split(' ');
int N = int.Parse(inputs[0]);
int M = int.Parse(inputs[1]);
int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int total = A.Sum();
Array.Sort(A);
Array.Reverse(A);
if (A[M - 1] >= total / 4 / M) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Linq;
namespace AtCoder20200404 {
class Program {
static void Main(string[] args) {
String[] inputs = Console.ReadLine().Split(' ');
int N = int.Parse(inputs[0]);
int M = int.Parse(inputs[1]);
int[] A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int total = A.Sum();
Array.Sort(A);
Array.Reverse(A);
if (A[M - 1] * 4 * M >= total) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 85], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 161
| 8
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace ABC161 {
public class Solve {
public static void Main(string[] args) { new ABC_B(); }
}
public class ABC_A {
public ABC_A() {
var i = Ex.ReadIntArray();
Ex.Cw($"{i[2]} {i[0]} {i[1]}");
}
}
public class ABC_B {
public ABC_B() {
var l1 = Ex.ReadIntArray();
var arr = Ex.ReadLongArray();
// N 種類の商品
var n = l1[0];
// M個を選べる
var m = l1[1];
// 総投票数の1/4M未満である
long d = arr.Sum() / 4 / m;
var c = arr.Count(v => d < v);
Ex.Cw(m <= c);
}
public void Cw(bool b) {
if (b)
Ex.Cw("Yes");
else
Ex.Cw("No");
}
}
public class ABC_C {
public ABC_C() {
var l1 = Ex.ReadLongArray();
// Nの初期値
var n = l1[0];
// Kの差の絶対値で置き換える
var k = l1[1];
var a = n % k;
Ex.Cw(Math.Min(a, Math.Abs(a - k)));
}
}
public class ABC_D {
/// <summary>
/// 小さい方からK番目のルンルン数
/// </summary>
long k;
long n = 0;
long end = 0;
char[] arr;
long cou = 0;
public ABC_D() {
k = Ex.ReadLong;
long idx = 0;
while (cou < k) {
idx++;
end = idx;
arr = new char[end];
for (int i = 1; i <= 9; i++) {
dfs(0, i);
}
}
}
long check(long pre) {
n += 3 * pre;
return 3 * pre;
}
long checkedge(long pre) {
n += 2 * pre;
return 2 * pre;
}
void dfs(long idx, int t) {
arr[idx] = (char)('0' + t);
if (end == (idx + 1)) {
cou++;
if (cou == k) {
Console.WriteLine(arr);
}
return;
}
if (cou >= k) {
return;
}
if (t == 0) {
dfs(idx + 1, 0);
dfs(idx + 1, 1);
return;
}
if (t == 9) {
dfs(idx + 1, 8);
dfs(idx + 1, 9);
return;
}
dfs(idx + 1, t - 1);
dfs(idx + 1, t);
dfs(idx + 1, t + 1);
return;
}
}
public class ABC_E {
public ABC_E() {}
}
public class ABC_F {
public ABC_F() {}
}
public static class Ex {
public static void Cw(object s) { Console.WriteLine(s); }
public static void Cw(bool b) {
if (b)
Cw("Yes");
else
Cw("No");
}
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(s => int.Parse(s)).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(s => long.Parse(s)).ToArray();
}
public static string[] ReadArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public static int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public static long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace ABC161 {
public class Solve {
public static void Main(string[] args) { new ABC_B(); }
}
public class ABC_A {
public ABC_A() {
var i = Ex.ReadIntArray();
Ex.Cw($"{i[2]} {i[0]} {i[1]}");
}
}
public class ABC_B {
public ABC_B() {
var l1 = Ex.ReadIntArray();
var arr = Ex.ReadLongArray();
// N 種類の商品
var n = l1[0];
// M個を選べる
var m = l1[1];
// 総投票数の1/4M未満である
long d = arr.Sum();
var c = arr.Count(v => d <= v * 4 * m);
Ex.Cw(m <= c);
}
public void Cw(bool b) {
if (b)
Ex.Cw("Yes");
else
Ex.Cw("No");
}
}
public class ABC_C {
public ABC_C() {
var l1 = Ex.ReadLongArray();
// Nの初期値
var n = l1[0];
// Kの差の絶対値で置き換える
var k = l1[1];
var a = n % k;
Ex.Cw(Math.Min(a, Math.Abs(a - k)));
}
}
public class ABC_D {
/// <summary>
/// 小さい方からK番目のルンルン数
/// </summary>
long k;
long n = 0;
long end = 0;
char[] arr;
long cou = 0;
public ABC_D() {
k = Ex.ReadLong;
long idx = 0;
while (cou < k) {
idx++;
end = idx;
arr = new char[end];
for (int i = 1; i <= 9; i++) {
dfs(0, i);
}
}
}
long check(long pre) {
n += 3 * pre;
return 3 * pre;
}
long checkedge(long pre) {
n += 2 * pre;
return 2 * pre;
}
void dfs(long idx, int t) {
arr[idx] = (char)('0' + t);
if (end == (idx + 1)) {
cou++;
if (cou == k) {
Console.WriteLine(arr);
}
return;
}
if (cou >= k) {
return;
}
if (t == 0) {
dfs(idx + 1, 0);
dfs(idx + 1, 1);
return;
}
if (t == 9) {
dfs(idx + 1, 8);
dfs(idx + 1, 9);
return;
}
dfs(idx + 1, t - 1);
dfs(idx + 1, t);
dfs(idx + 1, t + 1);
return;
}
}
public class ABC_E {
public ABC_E() {}
}
public class ABC_F {
public ABC_F() {}
}
public static class Ex {
public static void Cw(object s) { Console.WriteLine(s); }
public static void Cw(bool b) {
if (b)
Cw("Yes");
else
Cw("No");
}
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(s => int.Parse(s)).ToArray();
}
public static long[] ReadLongArray() {
return Read.Split(' ').Select(s => long.Parse(s)).ToArray();
}
public static string[] ReadArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public static int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public static long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 16, 17, 18], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 17, 19], ["+", 0, 218, 8, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 218, 8, 16, 12, 16, 31, 16, 12, 203], ["+", 0, 28, 0, 218, 8, 16, 12, 16, 17, 48], ["+", 0, 28, 0, 218, 8, 16, 12, 16, 12, 22]]
| 8
| 938
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC161 {
class Program {
static void Main(string[] args) { b(); }
public static void b() {
int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int n = nm[0], m = nm[1];
int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int asum = a.Sum(), b = 4 * m;
int sum = 0;
double min = asum / b;
for (int i = 0; i < n; i++) {
if (a[i] > min)
sum++;
}
if (sum >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ABC161 {
class Program {
static void Main(string[] args) { b(); }
public static void b() {
int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int n = nm[0], m = nm[1];
int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int sum = a.Sum();
int ans = 0;
for (int i = 0; i < n; i++) {
if (a[i] * (4 * m) >= sum)
ans++;
}
if (ans >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 12, 23, 0, 24], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 31, 203], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 211
| 29
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
string[] str =
Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得
int N = int.Parse(str[0]);
int M = int.Parse(str[1]);
str = Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得
int[] a = new int[N];
for (int i = 0; i < N; i++) {
a[i] = int.Parse(str[i]); //数値で受け取りたい場合は変換す
}
int count = 0;
for (int i = 0; i < N; i++) {
if (a[i] >= a.Sum() / (4 * M)) {
count++;
}
}
if (count >= M) {
Console.Write("Yes"); //改行なし出力
} else {
Console.Write("No"); //改行なし出力
}
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
string[] str =
Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得
int N = int.Parse(str[0]);
int M = int.Parse(str[1]);
str = Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得
int[] a = new int[N];
for (int i = 0; i < N; i++) {
a[i] = int.Parse(str[i]); //数値で受け取りたい場合は変換す
}
int count = 0;
float sum = a.Sum();
float aa = 4 * M;
for (int i = 0; i < N; i++) {
if (a[i] < sum / aa) {
count++;
}
}
if ((N - count) >= M) {
Console.Write("Yes"); //改行なし出力
} else {
Console.Write("No"); //改行なし出力
}
}
}
|
[["+", 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, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 48], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["-", 15, 16, 12, 16, 31, 213, 63, 214, 205, 22], ["-", 15, 16, 12, 16, 31, 213, 63, 214, 0, 131], ["-", 15, 16, 12, 16, 31, 213, 63, 214, 141, 22], ["-", 15, 16, 12, 16, 31, 213, 3, 4, 0, 24], ["-", 15, 16, 12, 16, 31, 213, 3, 4, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 16, 12, 23, 0, 24], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 31, 203], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 17, 48], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 57, 15, 16, 12, 16, 12, 23, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 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], ["+", 8, 196, 0, 57, 15, 16, 31, 23, 0, 25]]
| 8
| 204
| 34
|
using System;
using System.Linq;
class Program {
static void Main() {
int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
long ASUM = A.Sum();
long MAX = ASUM / (4 * N[1]);
int j = 0;
for (int i = 0; i < N[0]; ++i) {
if (A[i] >= MAX) {
j++;
}
}
if (j >= N[1]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
long ASUM = A.Sum();
double MAX = (double)ASUM / (4 * N[1]);
int j = 0;
for (int k = 0; k < N[0]; ++k) {
if (A[k] >= MAX) {
j++;
}
}
if (j >= N[1]) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["-", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 241, 0, 22], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22]]
| 8
| 180
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace atCoder161 {
class ClassB {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int N = int.Parse(str[0]);
int M = int.Parse(str[1]);
string[] ary = Console.ReadLine().Split(' ');
int[] A = ary.Select(int.Parse).ToArray();
List<int> listA = new List<int>(A);
int sum = listA.Sum();
int limit = sum / 4 / M;
List<int> sorted = listA.OrderByDescending(v => v).ToList();
if (sorted[M - 1] < limit) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace atCoder161 {
class ClassB {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int N = int.Parse(str[0]);
int M = int.Parse(str[1]);
string[] ary = Console.ReadLine().Split(' ');
decimal[] A = ary.Select(decimal.Parse).ToArray();
List<decimal> listA = new List<decimal>(A);
decimal sum = listA.Sum();
decimal limit = sum / 4 / M;
List<decimal> sorted = listA.OrderByDescending(v => v).ToList();
if (sorted[M - 1] < limit) {
Console.WriteLine("No");
} else {
Console.WriteLine("Yes");
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["+", 0, 197, 0, 198, 39, 236, 237, 238, 0, 199], ["-", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 205
| 14
|
using System;
using System.Linq;
namespace AtCoderCS {
class Program {
static void Main(string[] args) {
var input1 = Console.ReadLine();
var input1array = input1.Split(' ');
var N = int.Parse(input1array[0]);
var M = int.Parse(input1array[1]);
var input2 = Console.ReadLine();
var Astr = input2.Split(' ');
var A = new int[Astr.Length];
for (int i = 0; i < A.Length; i++) {
A[i] = int.Parse(Astr[i]);
}
Array.Sort(A);
var compareValue = A.Sum() / ((double)4 * M);
var camparedValue = A[N - 1];
var returnValue = camparedValue >= compareValue ? "Yes" : "No";
Console.WriteLine(returnValue);
}
}
}
|
using System;
using System.Linq;
namespace AtCoderCS {
class Program {
static void Main(string[] args) {
var input1 = Console.ReadLine();
var input1Arr = input1.Split(' ');
var N = int.Parse(input1Arr[0]);
var M = int.Parse(input1Arr[1]);
var input2 = Console.ReadLine();
var input2Arr = input2.Split(' ');
var A = new int[N];
for (int i = 0; i < A.Length; i++) {
A[i] = int.Parse(input2Arr[i]);
}
Array.Sort(A);
var comparedValue = A[A.Length - M];
var compareValue = A.Sum() / ((double)4 * M);
var returnValue = comparedValue >= compareValue ? "Yes" : "No";
Console.WriteLine(returnValue);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 214, 205, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 214, 0, 131], ["-", 0, 227, 39, 224, 225, 226, 0, 214, 141, 22], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 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, 204, 205, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 205, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 0, 131], ["+", 206, 207, 0, 28, 0, 16, 31, 214, 141, 22], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["+", 0, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 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, 204, 205, 22], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 31, 22], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 0, 204, 206, 207, 0, 28, 0, 16, 12, 203], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["-", 0, 200, 0, 212, 0, 41, 15, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 41, 15, 16, 31, 22]]
| 8
| 196
| 38
|
using System;
using System.Linq;
namespace algo {
class Program {
static void Main(string[] args) {
var input1 = Console.ReadLine().Split(' ');
int N = int.Parse(input1[0]);
int M = int.Parse(input1[1]);
var input2 = Console.ReadLine().Split(' ');
int[] A = input2.Select(x => int.Parse(x)).ToArray();
int sum = 0;
for (int i = 0; i < A.Length; ++i) {
sum += A[i];
}
int limit = sum / (4 * M);
int count = 0;
for (int j = 0; j < A.Length; ++j) {
if (A[j] < limit)
continue;
++count;
}
if (count >= M)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
namespace algo {
class Program {
static void Main(string[] args) {
var input1 = Console.ReadLine().Split(' ');
int N = int.Parse(input1[0]);
int M = int.Parse(input1[1]);
var input2 = Console.ReadLine().Split(' ');
int[] A = input2.Select(x => int.Parse(x)).ToArray();
int sum = 0;
for (int i = 0; i < A.Length; i++) {
sum += A[i];
}
float limit = (float)sum / (4 * M);
int count = 0;
for (int j = 0; j < A.Length; ++j) {
if (A[j] < limit)
continue;
count++;
}
if (count >= M)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 26, 241, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["-", 0, 7, 8, 196, 0, 1, 0, 241, 0, 29], ["+", 0, 7, 8, 196, 0, 1, 0, 223, 0, 29]]
| 8
| 211
| 9
|
public class Hello {
public static void Main() {
var line = System.Console.ReadLine();
string[] array = line.Split(' ');
int n = int.Parse(array[0]);
int m = int.Parse(array[1]);
var line2 = System.Console.ReadLine();
string[] array2 = line2.Split(' ');
int sum = 0;
for (int i = 0; i < n; i++) {
sum += int.Parse(array2[i]);
}
int border = 0;
border = sum / 4 / m;
int count = 0;
for (int j = 0; j < n; j++) {
int buf = int.Parse(array2[j]);
if (buf >= border) {
count++;
}
}
if (count >= m) {
System.Console.WriteLine("Yes");
} else {
System.Console.WriteLine("No");
}
}
}
|
public class Hello {
public static void Main() {
var line = System.Console.ReadLine();
string[] array = line.Split(' ');
int n = int.Parse(array[0]);
int m = int.Parse(array[1]);
var line2 = System.Console.ReadLine();
string[] array2 = line2.Split(' ');
int sum = 0;
for (int i = 0; i < n; i++) {
sum += int.Parse(array2[i]);
}
// int border = 0;
// border = sum / (4 * m);
int count = 0;
for (int j = 0; j < n; j++) {
int buf = int.Parse(array2[j]);
if (buf * 4 * m >= sum) {
count++;
}
}
if (count >= m) {
System.Console.WriteLine("Yes");
} else {
System.Console.WriteLine("No");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 17, 85], ["-", 0, 1, 0, 11, 12, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 213
| 19
|
using System;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = NM[0];
var M = NM[1];
var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var sum = A.Sum();
var limit = sum / (4 * M);
var get = 0;
foreach (int a in A) {
if (a > limit)
get++;
}
Console.WriteLine(get >= M ? "Yes" : "No");
}
}
}
|
using System;
using System.Linq;
namespace B {
class Program {
static void Main(string[] args) {
var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = NM[0];
var M = NM[1];
var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var sum = A.Sum();
var limit = (double)sum / (double)(4 * M);
var get = 0;
foreach (int a in A) {
if ((double)a >= limit)
get++;
}
Console.WriteLine(get >= M ? "Yes" : "No");
}
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25], ["+", 0, 212, 0, 16, 12, 74, 51, 23, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 39, 199], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 0, 25], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 153
| 11
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] NM = Console.ReadLine().Split(' ');
int N = int.Parse(NM[0]);
int M = int.Parse(NM[1]);
string[] Astr = Console.ReadLine().Split(' ');
int[] A = new int[N];
for (int i = 0; i < N; i++)
A[i] = int.Parse(Astr[i]);
int Sum = A.Sum();
int min = Sum / 4 / M;
int count = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= min)
count++;
}
if (count < M)
Console.WriteLine("No");
else
Console.WriteLine("Yes");
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] NM = Console.ReadLine().Split(' ');
int N = int.Parse(NM[0]);
int M = int.Parse(NM[1]);
string[] Astr = Console.ReadLine().Split(' ');
int[] A = new int[N];
for (int i = 0; i < N; i++)
A[i] = int.Parse(Astr[i]);
int Sum = A.Sum();
int min = Sum / 4 / M;
if (Sum % (4 * M) > 0)
min++;
int count = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= min)
count++;
}
if (count < M)
Console.WriteLine("No");
else
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, 109], ["+", 0, 57, 15, 16, 31, 16, 12, 23, 0, 24], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 31, 203], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 23, 0, 25], ["+", 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], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 22], ["+", 8, 196, 0, 57, 64, 1, 0, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 205
| 15
|
using System;
namespace AtCoder {
class MainClass {
public static void Main() {
string[] input1 = Console.ReadLine().Split(' ');
int N = int.Parse(input1[0]);
int M = int.Parse(input1[1]);
string[] input2 = Console.ReadLine().Split(' ');
int[] A = new int[N];
int total = 0;
for (int i = 0; i <= N - 1; i++) {
A[i] = int.Parse(input2[i]);
total += A[i];
}
int standard = total / (4 * M);
int count = 0;
for (int j = 0; j <= N - 1; j++) {
if (A[j] > standard) {
count++;
}
}
if (count >= M) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace AtCoder {
class MainClass {
public static void Main() {
string[] input1 = Console.ReadLine().Split(' ');
int N = int.Parse(input1[0]);
int M = int.Parse(input1[1]);
string[] input2 = Console.ReadLine().Split(' ');
int[] A = new int[N];
int total = 0;
for (int i = 0; i <= N - 1; i++) {
A[i] = int.Parse(input2[i]);
total += A[i];
}
float t = (float)total;
float standard = t / (4 * M);
int count = 0;
for (int j = 0; j <= N - 1; j++) {
if (A[j] >= standard) {
count++;
}
}
if (count >= M) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 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, 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], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 214
| 14
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace B {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var sum = ai.Sum();
var threthold = sum / (4 * nm[1]);
var canSelect = false;
var count = 0;
for (var i = 0; i < ai.Length; i++) {
if (ai[i] >= threthold) {
count++;
}
}
if (count >= nm[1])
canSelect = true;
Console.WriteLine(canSelect ? "Yes" : "No");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace B {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var sum = ai.Sum();
var canSelect = false;
var count = 0;
for (var i = 0; i < ai.Length; i++) {
if (ai[i] * 4 * nm[1] >= sum) {
count++;
}
}
if (count >= nm[1])
canSelect = true;
Console.WriteLine(canSelect ? "Yes" : "No");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 31, 203], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 17, 48], ["-", 0, 16, 12, 23, 0, 16, 12, 204, 205, 22], ["-", 12, 23, 0, 16, 12, 204, 206, 207, 0, 70], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 23, 0, 16, 12, 204, 206, 207, 0, 73], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 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, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 245
| 23
|
using System;
class ProgramB {
static void Main(string[] args) {
//入力
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long m = long.Parse(s[1]);
string[] a = Console.ReadLine().Split(' ');
long[] ai = new long[n];
long sum = 0;
long count = 0;
for (int i = 0; i < n; i++) {
ai[i] = long.Parse(a[i]);
sum += ai[i];
}
for (int i = 0; i < n; i++) {
if (ai[i] >= sum / 4 / m)
count++;
}
if (count >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
using System;
class ProgramB {
static void Main(string[] args) {
//入力
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long m = long.Parse(s[1]);
string[] a = Console.ReadLine().Split(' ');
long[] ai = new long[n];
long sum = 0;
long count = 0;
for (int i = 0; i < n; i++) {
ai[i] = long.Parse(a[i]);
sum += ai[i];
}
for (int i = 0; i < n; i++) {
if (ai[i] >= (double)sum / 4.0 / (double)m)
count++;
}
if (count >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
[["+", 15, 16, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 15, 16, 12, 16, 31, 16, 31, 74, 39, 199], ["+", 15, 16, 12, 16, 31, 16, 31, 74, 0, 25], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 250], ["+", 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, 0, 25]]
| 8
| 197
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AtCoder_Core {
class Program {
static void Main(string[] args) {
var line1 = Console.ReadLine()
.Trim()
.Split(' ')
.Select(b => int.Parse(b))
.ToArray();
int N = line1[0];
int M = line1[1];
var A = Console.ReadLine()
.Trim()
.Split(' ')
.Select(c => int.Parse(c))
.ToArray();
Array.Sort(A);
int selected = 0;
for (int i = 0; i < A.Length; i++) {
if (A[i] >= (A.Sum() / (4 * M))) {
selected++;
}
}
if (selected >= M) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace AtCoder_Core {
class Program {
static void Main(string[] args) {
var line1 = Console.ReadLine()
.Trim()
.Split(' ')
.Select(b => int.Parse(b))
.ToArray();
int N = line1[0];
int M = line1[1];
var A = Console.ReadLine()
.Trim()
.Split(' ')
.Select(c => int.Parse(c))
.ToArray();
Array.Sort(A);
int selected = 0;
for (int i = 0; i < A.Length; i++) {
double lr = Math.Ceiling(((double)A.Sum() / (4.0 * (double)M)));
if (A[i] >= lr) {
selected++;
}
}
if (selected >= M) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 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, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 8, 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, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 28, 0, 23, 0, 16, 31, 74, 0, 24], ["+", 0, 28, 0, 23, 0, 16, 31, 74, 39, 199], ["+", 0, 28, 0, 23, 0, 16, 31, 74, 0, 25], ["-", 12, 23, 0, 16, 12, 23, 0, 16, 31, 203], ["+", 0, 23, 0, 16, 12, 23, 0, 16, 31, 250], ["+", 0, 16, 12, 23, 0, 16, 12, 74, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 12, 74, 39, 199], ["+", 0, 16, 12, 23, 0, 16, 12, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 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, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 214
| 30
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var M = cin.ReadInt;
var arrayA = new int[N];
var sumA = 0;
for (int i = 0; i < N; i++) {
arrayA[i] = cin.ReadInt;
sumA += arrayA[i];
}
var count = 0;
double checkA = sumA / (4 * M);
var ans = false;
foreach (var item in arrayA) {
if (item >= checkA) {
count++;
}
if (count >= M) {
ans = true;
break;
}
}
WriteLine(ans ? "Yes" : "No");
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; i++)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadInt;
var M = cin.ReadInt;
var arrayA = new int[N];
var sumA = 0;
for (int i = 0; i < N; i++) {
arrayA[i] = cin.ReadInt;
sumA += arrayA[i];
}
var count = 0;
double checkA = (double)sumA / (4.0 * (double)M);
var ans = false;
foreach (var item in arrayA) {
if ((double)item >= checkA) {
count++;
}
if (count >= M) {
ans = true;
break;
}
}
WriteLine(ans ? "Yes" : "No");
}
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; i++)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 31, 203], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 31, 250], ["+", 0, 16, 12, 23, 0, 16, 12, 74, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 12, 74, 39, 199], ["+", 0, 16, 12, 23, 0, 16, 12, 74, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 39, 199], ["+", 8, 196, 0, 57, 15, 16, 31, 74, 0, 25]]
| 8
| 552
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
class Program {
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] NMK = Console.ReadLine().Split(' ');
int N = int.Parse(NMK[0]);
int M = int.Parse(NMK[1]);
string[] items = Console.ReadLine().Split(' ');
List<int> point = new List<int>();
int sum = 0;
for (int i = 0; i < items.Length; i++) {
int a = int.Parse(items[i]);
point.Add(a);
sum += a;
}
point.Sort();
for (int i = N - 1; i > N - 1 - M; i--) {
int b = point[i];
if (b < sum / (4 * M)) {
Console.WriteLine("No");
return;
}
}
// 文字列の入力
// string s = Console.ReadLine();
//出力
// Console.WriteLine((a+b+c) + " " + s);
Console.WriteLine("Yes");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
class Program {
static void Main(string[] args) {
// 整数の入力
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
string[] NMK = Console.ReadLine().Split(' ');
int N = int.Parse(NMK[0]);
int M = int.Parse(NMK[1]);
string[] items = Console.ReadLine().Split(' ');
List<int> point = new List<int>();
int sum = 0;
for (int i = 0; i < items.Length; i++) {
int a = int.Parse(items[i]);
point.Add(a);
sum += a;
}
point.Sort();
for (int i = N - 1; i > N - 1 - M; i--) {
decimal b = (decimal)point[i];
decimal c = (decimal)sum / (4 * M);
// Console.WriteLine(b + " " + c);
if (b < c) {
Console.WriteLine("No");
return;
}
}
// 文字列の入力
// string s = Console.ReadLine();
//出力
// Console.WriteLine((a+b+c) + " " + s);
Console.WriteLine("Yes");
}
}
|
[["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 243
| 19
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = int.Parse(Console.ReadLine());
int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
var n = nm[0];
var m = nm[1];
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
var sum = a.Sum();
var tmp = sum / (4 * m);
Array.Sort(a);
Array.Reverse(a);
var ans = "Yes";
for (int i = 0; i < m; i++) {
if (a[i] < tmp) {
ans = "No";
break;
}
}
// 出力
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = int.Parse(Console.ReadLine());
int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
var n = nm[0];
var m = nm[1];
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
var sum = a.Sum();
Array.Sort(a);
Array.Reverse(a);
var ans = "Yes";
for (int i = 0; i < m; i++) {
var tmp = a[i] * 4 * m;
if (sum > tmp) {
ans = "No";
break;
}
}
// 出力
Console.WriteLine(ans);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 31, 203], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 17, 48], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 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, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 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, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47]]
| 8
| 195
| 26
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var n = inputs[0];
var m = inputs[1];
var ai = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
var count = ai.Where(t => t >= (ai.Sum() / (4 * m))).Count();
if (count >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var n = inputs[0];
var m = inputs[1];
var ai = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var count =
ai.Where(t => (double)t >= (double)((double)ai.Sum() / (double)(4 * m)))
.Count();
if (count >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 0, 28, 0, 218, 8, 16, 31, 74, 0, 24], ["+", 0, 28, 0, 218, 8, 16, 31, 74, 39, 199], ["+", 0, 28, 0, 218, 8, 16, 31, 74, 0, 25], ["+", 0, 28, 0, 218, 8, 16, 12, 74, 0, 24], ["+", 0, 28, 0, 218, 8, 16, 12, 74, 39, 199], ["+", 0, 28, 0, 218, 8, 16, 12, 74, 0, 25], ["+", 12, 74, 51, 23, 0, 16, 31, 74, 0, 24], ["+", 12, 74, 51, 23, 0, 16, 31, 74, 39, 199], ["+", 12, 74, 51, 23, 0, 16, 31, 74, 0, 25], ["+", 12, 74, 51, 23, 0, 16, 12, 74, 0, 24], ["+", 12, 74, 51, 23, 0, 16, 12, 74, 39, 199], ["+", 12, 74, 51, 23, 0, 16, 12, 74, 0, 25]]
| 8
| 148
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
public static long mod = 1000000007;
void calc() {
cin = new Scanner();
cin2 = new Func();
int N = cin.nextInt();
int M = cin.nextInt();
int[] a = cin.ArrayInt(N, 0);
int x = 0;
int sum = 0;
string ans = "No";
for (int i = 0; i < N; i++)
sum += a[i];
for (int i = 0; i < N; i++)
if (a[i] >= sum / (4 * M))
x++;
if (x >= M)
ans = "Yes";
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Answer {
public void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
public void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public static long mod = 1000000007;
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
public long mod_pow(long x, long n) {
long ans = 1;
while (n > 0) {
if ((n & 1) == 1) {
ans = ans * x;
ans %= mod;
}
x = x * x % mod;
n >>= 1;
}
return ans;
}
public long factorial(long x) {
long n = 1;
if (x <= 1)
return x;
else {
n *= (x * factorial(x - 1));
n %= mod;
return n;
}
}
public long combination(long n, long r) {
if (r * 2 > n)
r = n - r;
long dividend = 1;
long divisor = 1;
for (long i = 1; i <= r; ++i) {
dividend *= (n - i + 1);
dividend %= mod;
divisor *= i;
divisor %= mod;
}
return (dividend * mod_pow(divisor, mod - 2)) % mod;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
public static long mod = 1000000007;
void calc() {
cin = new Scanner();
cin2 = new Func();
int N = cin.nextInt();
int M = cin.nextInt();
int[] a = cin.ArrayInt(N, 0);
int x = 0;
int sum = 0;
string ans = "No";
for (int i = 0; i < N; i++)
sum += a[i];
for (int i = 0; i < N; i++)
if ((double)a[i] >= (double)sum / (4 * (double)M))
x++;
if (x >= M)
ans = "Yes";
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Answer {
public void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
public void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public static long mod = 1000000007;
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
public long mod_pow(long x, long n) {
long ans = 1;
while (n > 0) {
if ((n & 1) == 1) {
ans = ans * x;
ans %= mod;
}
x = x * x % mod;
n >>= 1;
}
return ans;
}
public long factorial(long x) {
long n = 1;
if (x <= 1)
return x;
else {
n *= (x * factorial(x - 1));
n %= mod;
return n;
}
}
public long combination(long n, long r) {
if (r * 2 > n)
r = n - r;
long dividend = 1;
long divisor = 1;
for (long i = 1; i <= r; ++i) {
dividend *= (n - i + 1);
dividend %= mod;
divisor *= i;
divisor %= mod;
}
return (dividend * mod_pow(divisor, mod - 2)) % mod;
}
}
|
[["+", 0, 7, 8, 57, 15, 16, 31, 74, 0, 24], ["+", 0, 7, 8, 57, 15, 16, 31, 74, 39, 199], ["+", 0, 7, 8, 57, 15, 16, 31, 74, 0, 25], ["+", 8, 57, 15, 16, 12, 16, 31, 74, 0, 24], ["+", 8, 57, 15, 16, 12, 16, 31, 74, 39, 199], ["+", 8, 57, 15, 16, 12, 16, 31, 74, 0, 25], ["+", 12, 16, 12, 23, 0, 16, 12, 74, 0, 24], ["+", 12, 16, 12, 23, 0, 16, 12, 74, 39, 199], ["+", 12, 16, 12, 23, 0, 16, 12, 74, 0, 25]]
| 8
| 1,016
| 9
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace b {
class Program {
static void Main(string[] args) {
var _ = Console.ReadLine().Split();
var n = int.Parse(_[0]);
var m = int.Parse(_[1]);
var a = Console.ReadLine()
.Split()
.Select(i => int.Parse(i))
.OrderByDescending(i => i)
.ToArray();
var count = 0;
var vote = a.Sum();
var limit = vote / (4 * m);
for (var i = 0; i < m; i++) {
if (a[i] >= limit) {
count++;
}
}
Console.WriteLine(count == m ? "Yes" : "No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace b {
class Program {
static void Main(string[] args) {
var _ = Console.ReadLine().Split();
var n = int.Parse(_[0]);
var m = int.Parse(_[1]);
var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
var count = 0;
var vote = a.Sum();
var limit = vote % (4 * m) == 0 ? vote / (4 * m) : vote / (4 * m) + 1;
for (var i = 0; i < n; i++) {
if (a[i] >= limit) {
count++;
}
}
Console.WriteLine(count >= m ? "Yes" : "No");
}
}
}
|
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["-", 205, 213, 3, 4, 0, 28, 0, 218, 8, 22], ["-", 0, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 212, 0, 41, 15, 16, 31, 16, 17, 109], ["+", 0, 41, 15, 16, 31, 16, 12, 23, 0, 24], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 31, 203], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 41, 15, 16, 31, 16, 12, 23, 0, 25], ["+", 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, 16, 31, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 0, 102], ["+", 0, 212, 0, 41, 75, 16, 31, 16, 31, 22], ["+", 0, 212, 0, 41, 75, 16, 31, 16, 17, 85], ["+", 0, 41, 75, 16, 31, 16, 12, 23, 0, 24], ["+", 75, 16, 31, 16, 12, 23, 0, 16, 31, 203], ["+", 75, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 75, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 41, 75, 16, 31, 16, 12, 23, 0, 25], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 41, 75, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 20]]
| 8
| 181
| 31
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var firstLine = Console.ReadLine()
.Split(' ')
.Select(value => int.Parse(value))
.ToList();
var m = firstLine[1];
var aList = Console.ReadLine()
.Split(' ')
.Select(value => int.Parse(value))
.ToList();
var totalVote = aList.Sum();
var str =
aList.Count(value => value >= totalVote / (4 * m)) >= m ? "Yes" : "No";
Console.WriteLine(str);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var firstLine = Console.ReadLine()
.Split(' ')
.Select(value => int.Parse(value))
.ToList();
var m = firstLine[1];
var aList = Console.ReadLine()
.Split(' ')
.Select(value => int.Parse(value))
.ToList();
var totalVote = aList.Sum();
var threshold = (double)totalVote / (double)(4 * m);
var str = aList.Count(value => value >= threshold) >= m ? "Yes" : "No";
Console.WriteLine(str);
}
}
}
|
[["+", 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, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 51, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 12, 74, 0, 25], ["+", 0, 212, 0, 16, 12, 74, 51, 23, 0, 24], ["+", 0, 16, 12, 74, 51, 23, 0, 16, 31, 203], ["+", 0, 16, 12, 74, 51, 23, 0, 16, 17, 48], ["+", 0, 16, 12, 74, 51, 23, 0, 16, 12, 22], ["+", 0, 212, 0, 16, 12, 74, 51, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 28, 0, 218, 8, 16, 12, 16, 31, 22], ["-", 0, 28, 0, 218, 8, 16, 12, 16, 17, 85], ["-", 0, 218, 8, 16, 12, 16, 12, 23, 0, 24], ["-", 8, 16, 12, 16, 12, 23, 0, 16, 31, 203], ["-", 8, 16, 12, 16, 12, 23, 0, 16, 17, 48], ["-", 8, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 218, 8, 16, 12, 16, 12, 23, 0, 25], ["+", 3, 4, 0, 28, 0, 218, 8, 16, 12, 22]]
| 8
| 157
| 25
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999999;
public static void Main(string[] args) {
var p = Input().ToInt();
var n = p[0];
var m = p[1];
var a = Input().ToInt();
int k = 0;
long wa = 0;
for (int i = 0; i < n; i++) {
wa += a[i];
}
for (int i = 0; i < n; i++) {
if (a[i] > wa / (4 * m))
k++;
}
Console.WriteLine(k >= m ? "Yes" : "No");
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass {
public const long Giri = 1000000007;
public const long DpInf = 99999999999999;
public static void Main(string[] args) {
var p = Input().ToInt();
var n = p[0];
var m = p[1];
var a = Input().ToInt();
int k = 0;
long wa = 0;
for (int i = 0; i < n; i++) {
wa += a[i];
}
double op = (double)wa / (4 * m);
for (int i = 0; i < n; i++) {
if (a[i] >= op)
k++;
}
Console.WriteLine(k >= m ? "Yes" : "No");
}
static long GCD(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
public static string[] Input() { return Console.ReadLine().Split(); }
}
public static class Smarter {
public static int ToInt(this string str) { return int.Parse(str); }
public static long ToLong(this string str) { return long.Parse(str); }
public static int[] ToInt(this string[] str, int offset = 0) {
var r = new int[str.Length];
for (int i = 0; i < str.Length; i++)
r[i] = str[i].ToInt() + offset;
return r;
}
}
|
[["+", 0, 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, 74, 0, 24], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 39, 199], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 0, 25], ["+", 0, 200, 0, 212, 0, 16, 31, 74, 51, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 31, 203], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 17, 48], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 16, 12, 16, 12, 23, 0, 24], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 31, 203], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 17, 48], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 57, 15, 16, 12, 16, 12, 23, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 367
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleTest {
static partial class Program {
static void Main(string[] args) {
var v = Ints();
int n = v[0];
int m = v[1];
var a = Ints();
var sum = a.Sum();
int thr = sum / (4 * m);
int num = 0;
for (int i = 0; i < a.Length; ++i) {
if (a[i] >= thr)
++num;
}
if (num >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
static partial class Program {
public static int Int() { return int.Parse(Console.ReadLine()); }
public static int[] Ints() {
return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
public static int[][] MultiInts(int num) {
var result = new int [num][];
for (int i = 0; i < num; ++i) {
result[i] = Ints();
}
return result;
}
public static T[] MultiItems<T>(int num, Func<string, T> parser) {
var result = new T[num];
for (int i = 0; i < num; ++i) {
result[i] = parser(Console.ReadLine());
}
return result;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleTest {
static partial class Program {
static void Main(string[] args) {
var v = Ints();
int n = v[0];
int m = v[1];
var a = Ints();
var sum = a.Sum();
int thr = sum;
int num = 0;
for (int i = 0; i < a.Length; ++i) {
if (4 * m * a[i] >= thr)
++num;
}
if (num >= m)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
static partial class Program {
public static int Int() { return int.Parse(Console.ReadLine()); }
public static int[] Ints() {
return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
public static int[][] MultiInts(int num) {
var result = new int [num][];
for (int i = 0; i < num; ++i) {
result[i] = Ints();
}
return result;
}
public static T[] MultiItems<T>(int num, Func<string, T> parser) {
var result = new T[num];
for (int i = 0; i < num; ++i) {
result[i] = parser(Console.ReadLine());
}
return result;
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 24], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 31, 203], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 17, 48], ["-", 0, 212, 0, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 200, 0, 212, 0, 16, 12, 23, 0, 25], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 48], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48]]
| 8
| 335
| 10
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class B {
static StreamWriter Out =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
int N, M;
Input(out N, out M);
int[] A;
Inputs(out A);
int count = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= 4 * M) {
count++;
}
}
if (count >= M) {
Print("Yes");
} else {
Print("No");
}
Out.Flush();
}
static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
static void Input<A>(out A a) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
}
static void Input<A, B>(out A a, out B b) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
}
static void Input<A, B, C>(out A a, out B b, out C c) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
}
static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
}
static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d,
out E e) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
}
static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d,
out E e, out F f) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
f = ChangeT<F>(words[5]);
}
static void Inputs<T>(out T[] array) {
array = Console.ReadLine()
.Split(new[] { ' ' },
options: StringSplitOptions.RemoveEmptyEntries)
.Select(s => ChangeT<T>(s))
.ToArray();
}
static void Print<T>(T s) => Out.WriteLine(s);
static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class B {
static StreamWriter Out =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static void Main(string[] args) {
int N, M;
Input(out N, out M);
int[] A;
Inputs(out A);
double sum = 0;
for (int i = 0; i < N; i++) {
sum += A[i];
}
int count = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= sum / (4 * M)) {
count++;
}
}
if (count >= M) {
Print("Yes");
} else {
Print("No");
}
Out.Flush();
}
static T ChangeT<T>(string s) => (T)Convert.ChangeType(s, typeof(T));
static void Input<A>(out A a) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
}
static void Input<A, B>(out A a, out B b) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
}
static void Input<A, B, C>(out A a, out B b, out C c) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
}
static void Input<A, B, C, D>(out A a, out B b, out C c, out D d) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
}
static void Input<A, B, C, D, E>(out A a, out B b, out C c, out D d,
out E e) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
}
static void Input<A, B, C, D, E, F>(out A a, out B b, out C c, out D d,
out E e, out F f) {
var words = Console.ReadLine().Split(
new[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
a = ChangeT<A>(words[0]);
b = ChangeT<B>(words[1]);
c = ChangeT<C>(words[2]);
d = ChangeT<D>(words[3]);
e = ChangeT<E>(words[4]);
f = ChangeT<F>(words[5]);
}
static void Inputs<T>(out T[] array) {
array = Console.ReadLine()
.Split(new[] { ' ' },
options: StringSplitOptions.RemoveEmptyEntries)
.Select(s => ChangeT<T>(s))
.ToArray();
}
static void Print<T>(T s) => Out.WriteLine(s);
static void Print<T>(params T[] s) => Out.WriteLine(string.Join(" ", s));
static void Print<T>(IEnumerable<T> e) => Out.WriteLine(string.Join(" ", e));
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 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, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 25], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 8, 196, 0, 1, 0, 11, 12, 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, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 16, 12, 16, 12, 23, 0, 24], ["+", 0, 57, 15, 16, 12, 16, 12, 23, 0, 25]]
| 8
| 912
| 32
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using AtCoderBeginnerContest161.Questions;
using AtCoderBeginnerContest161.Extensions;
namespace AtCoderBeginnerContest161 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionC(); // 問題に合わせて書き換え
var answers = question.Solve(Console.In);
foreach (var answer in answers) {
Console.WriteLine(answer);
}
}
}
}
namespace AtCoderBeginnerContest161.Questions {
// ここにQuestionクラスをコピペ
public class QuestionC : AtCoderQuestionBase {
public override IEnumerable<string> Solve(TextReader inputStream) {
var nk = inputStream.ReadLongArray();
var n = nk[0];
var k = nk[1];
var diff = Math.Abs(n - k);
if (diff > n) {
yield return n.ToString();
yield break;
}
n = n - diff * (n / diff);
yield return Math.Min(n, Math.Abs(n - k)).ToString();
}
}
#region Base Classes
public interface IAtCoderQuestion {
IEnumerable<string> Solve(string input);
IEnumerable<string> Solve(TextReader inputStream);
}
public abstract class AtCoderQuestionBase : IAtCoderQuestion {
public IEnumerable<string> Solve(string input) {
var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
var reader = new StreamReader(stream, Encoding.Unicode);
return Solve(reader);
}
public abstract IEnumerable<string> Solve(TextReader inputStream);
}
#endregion
}
#region Extensions
namespace AtCoderBeginnerContest161.Extensions {
internal static class TextReaderExtensions {
internal static int
ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
internal static long
ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
internal static double
ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
internal static string
ReadString(this TextReader reader) => reader.ReadLine();
internal static int[] ReadIntArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(int.Parse).ToArray();
internal static long[] ReadLongArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(long.Parse).ToArray();
internal static double[] ReadDoubleArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(double.Parse).ToArray();
internal static string[] ReadStringArray(this TextReader reader,
char separator = ' ') =>
reader.ReadLine().Split(separator);
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using AtCoderBeginnerContest161.Questions;
using AtCoderBeginnerContest161.Extensions;
namespace AtCoderBeginnerContest161 {
class Program {
static void Main(string[] args) {
IAtCoderQuestion question = new QuestionC(); // 問題に合わせて書き換え
var answers = question.Solve(Console.In);
foreach (var answer in answers) {
Console.WriteLine(answer);
}
}
}
}
namespace AtCoderBeginnerContest161.Questions {
// ここにQuestionクラスをコピペ
public class QuestionC : AtCoderQuestionBase {
public override IEnumerable<string> Solve(TextReader inputStream) {
var nk = inputStream.ReadLongArray();
var n = nk[0];
var k = nk[1];
var diff = Math.Abs(n - k);
if (diff > n) {
yield return n.ToString();
yield break;
}
n %= k;
yield return Math.Min(n, Math.Abs(n - k)).ToString();
}
}
#region Base Classes
public interface IAtCoderQuestion {
IEnumerable<string> Solve(string input);
IEnumerable<string> Solve(TextReader inputStream);
}
public abstract class AtCoderQuestionBase : IAtCoderQuestion {
public IEnumerable<string> Solve(string input) {
var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
var reader = new StreamReader(stream, Encoding.Unicode);
return Solve(reader);
}
public abstract IEnumerable<string> Solve(TextReader inputStream);
}
#endregion
}
#region Extensions
namespace AtCoderBeginnerContest161.Extensions {
internal static class TextReaderExtensions {
internal static int
ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
internal static long
ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
internal static double
ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
internal static string
ReadString(this TextReader reader) => reader.ReadLine();
internal static int[] ReadIntArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(int.Parse).ToArray();
internal static long[] ReadLongArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(long.Parse).ToArray();
internal static double[] ReadDoubleArray(this TextReader reader,
char separator = ' ') =>
ReadStringArray(reader, separator).Select(double.Parse).ToArray();
internal static string[] ReadStringArray(this TextReader reader,
char separator = ' ') =>
reader.ReadLine().Split(separator);
}
}
#endregion
|
[["-", 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], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 16, 17, 48], ["-", 0, 11, 12, 16, 12, 16, 12, 23, 0, 24], ["-", 12, 16, 12, 16, 12, 23, 0, 16, 31, 22], ["-", 12, 16, 12, 16, 12, 23, 0, 16, 17, 85], ["-", 12, 16, 12, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 11, 12, 16, 12, 16, 12, 23, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 546
| 12
|
using System;
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);
var N = sc.ReadLong();
var K = sc.ReadLong();
if (N == 0 || K == 0) {
Console.WriteLine(Math.Max(N, K));
return;
}
// if (N == 1 || K == 1)
//{
// Console.WriteLine(0);
// return;
//}
if (N % K == 0) {
Console.WriteLine(0);
return;
}
N = N % K;
var ans = Math.Min(N, Math.Abs(N - K));
Console.WriteLine(ans);
// if (Math.Max(N, K) % Math.Min(N, K) == 0)
//{
// var r = Math.Min(N, Math.Abs(N - K));
// Console.WriteLine(r);
// return;
//}
// var d = Math.Max(N, K) % Math.Min(N, K);
// var ans = Math.Min(N, d);
// ans = Math.Min(ans, Math.Abs(K - d));
// Console.WriteLine(ans);
// Console.Out.Flush();
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
class Program {
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var N = sc.ReadLong();
var K = sc.ReadLong();
if (N == 0) {
Console.WriteLine(0);
return;
}
if (K == 0) {
Console.WriteLine(Math.Max(N, K));
return;
}
// if (N == 1 || K == 1)
//{
// Console.WriteLine(0);
// return;
//}
if (N % K == 0) {
Console.WriteLine(0);
return;
}
N = N % K;
var ans = Math.Min(N, Math.Abs(N - K));
Console.WriteLine(ans);
// if (Math.Max(N, K) % Math.Min(N, K) == 0)
//{
// var r = Math.Min(N, Math.Abs(N - K));
// Console.WriteLine(r);
// return;
//}
// var d = Math.Max(N, K) % Math.Min(N, K);
// var ans = Math.Min(N, d);
// ans = Math.Min(ans, Math.Abs(K - d));
// Console.WriteLine(ans);
// Console.Out.Flush();
}
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, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24]]
| 8
| 1,121
| 15
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc161_c {
class Program {
static void Main(string[] args) {
string[] NK = Console.ReadLine().Split(' ');
double N = double.Parse(NK[0]);
double K = double.Parse(NK[1]);
double ans = 0;
if (N % K == 0) {
Console.WriteLine(0);
} else {
N = N % K;
if (Math.Abs(N - K) < N) {
N = Math.Abs(N - K);
}
Console.WriteLine(N);
}
Console.Read();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace abc161_c {
class Program {
static void Main(string[] args) {
string[] NK = Console.ReadLine().Split(' ');
long N = long.Parse(NK[0]);
long K = long.Parse(NK[1]);
if (N % K == 0) {
Console.WriteLine(0);
} else {
N = N % K;
if (Math.Abs(N - K) < N) {
N = Math.Abs(N - K);
}
Console.WriteLine(N);
}
Console.Read();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 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
| 160
| 13
|
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
class Program {
static void Main(string[] args) {
long[] longArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long N = longArray[0];
long K = longArray[1];
if (N % K == 0) {
N = 0;
} else if (N % K > Math.Abs(N - K)) {
N = Math.Abs(N - K);
} else {
N = N % K;
}
Console.WriteLine(N);
}
}
// string s = Console.ReadLine();
// int[] intArray = Console.ReadLine().Split(' ').Select(i =>
// int.Parse(i)).ToArray(); int H = intArray[0]; int W = intArray[1]; int N =
// int.Parse(Console.ReadLine()); List<int> A = new
// List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
// Boolean ok = false;
// Console.WriteLine(ans);
// Console.WriteLine("Yes");
// Console.WriteLine("No");
// Console.ReadKey();
// string[] strArray = Console.ReadLine().Split(' ').ToArray();
// string S = strArray[0];
// string T = strArray[1];
|
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
class Program {
static void Main(string[] args) {
long[] longArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long N = longArray[0];
long K = longArray[1];
N %= K;
if (N > Math.Abs(N - K)) {
N = Math.Abs(N - K);
}
Console.WriteLine(N);
}
}
// string s = Console.ReadLine();
// int[] intArray = Console.ReadLine().Split(' ').Select(i =>
// int.Parse(i)).ToArray(); int H = intArray[0]; int W = intArray[1]; int N =
// int.Parse(Console.ReadLine()); List<int> A = new
// List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
// Boolean ok = false;
// Console.WriteLine(ans);
// Console.WriteLine("Yes");
// Console.WriteLine("No");
// Console.ReadKey();
// string[] strArray = Console.ReadLine().Split(' ').ToArray();
// string S = strArray[0];
// string T = strArray[1];
|
[["-", 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, 17, 109], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["-", 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], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 109], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 57, 75, 57, 0, 95], ["-", 8, 196, 0, 57, 75, 57, 75, 196, 0, 45], ["-", 75, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 109], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 171
| 24
|
using System;
namespace C {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
string[] strs = line.Split(' ');
long N = long.Parse(strs[0]);
long K = long.Parse(strs[1]);
long min;
if (N < K) {
min = Math.Abs(N - K);
if (min > Math.Abs(K - N))
min = (K - N);
} else {
min = N % K;
if (min > Math.Abs(min - K))
min = Math.Abs(min - K);
}
Console.WriteLine(min);
}
}
}
|
using System;
namespace C {
class Program {
static void Main(string[] args) {
string line = Console.ReadLine();
string[] strs = line.Split(' ');
long N = long.Parse(strs[0]);
long K = long.Parse(strs[1]);
long min = N;
if (N < K) {
if (min > Math.Abs(N - K))
min = Math.Abs(N - K);
if (min > Math.Abs(K - N))
min = Math.Abs(K - N);
} else {
if (min > N % K)
min = N % K;
if (min > Math.Abs(min - K))
min = Math.Abs(min - K);
}
Console.WriteLine(min);
}
}
}
|
[["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 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, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 64, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 24], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 47], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 17, 109], ["+", 75, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 57, 75, 196, 0, 57, 0, 25]]
| 8
| 154
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace task3 {
class Program {
static void Main(string[] args) {
Int64[] input = Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();
Int64 N = input[0];
Int64 K = input[1];
Console.WriteLine(Math.Min(Math.Abs(N - K), K - Math.Abs(N - K)));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace task3 {
class Program {
static void Main(string[] args) {
Int64[] input = Console.ReadLine().Split(' ').Select(Int64.Parse).ToArray();
Int64 N = input[0];
Int64 K = input[1];
Console.WriteLine(Math.Min(N % K, K - (N % K)));
}
}
}
|
[["-", 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], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 109], ["-", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["-", 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], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 109]]
| 8
| 121
| 12
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.