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.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ใใใใ
static void Solve() {
int N = GetInt();
var xyh = GetIntJaggedArray(N)
.Select(s => new { x = s[0], y = s[1], h = s[2] })
.OrderByDescending(o => o.h)
.ToArray();
var f = xyh.First();
for (int ix = 0; ix <= 100; ix++) {
for (int iy = 0; iy <= 100; iy++) {
var ih = f.h + Math.Abs(ix - f.x) + Math.Abs(iy - f.y);
var ok = true;
for (int n = 0; n < N; n++) {
if (ih !=
xyh[n].h + Math.Abs(xyh[n].x - ix) + Math.Abs(xyh[n].y - iy)) {
ok = false;
break;
}
}
if (ok) {
Console.WriteLine(ix + " " + iy + " " + ih);
return;
}
}
}
}
}
//ๆกๅผตใกใฝใใ
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d,
out X e, out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
//ใใใใ
static void Solve() {
int N = GetInt();
var xyh = GetIntJaggedArray(N)
.Select(s => new { x = s[0], y = s[1], h = s[2] })
.OrderByDescending(o => o.h)
.ToArray();
var f = xyh.First();
for (int ix = 0; ix <= 100; ix++) {
for (int iy = 0; iy <= 100; iy++) {
var ih = f.h + Math.Abs(ix - f.x) + Math.Abs(iy - f.y);
var ok = true;
for (int n = 0; n < N; n++) {
if (xyh[n].h !=
Math.Max(ih - Math.Abs(xyh[n].x - ix) - Math.Abs(xyh[n].y - iy),
0)) {
ok = false;
break;
}
}
if (ok) {
Console.WriteLine(ix + " " + iy + " " + ih);
return;
}
}
}
}
}
//ๆกๅผตใกใฝใใ
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public T[][] CreateJaggedArray<T>(int H, int W, T value) {
return Enumerable.Repeat(0, H)
.Select(s => Enumerable.Repeat(value, W).ToArray())
.ToArray();
}
static public int[][] GetIntJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetIntArray().ToArray())
.ToArray();
}
static public long[][] GetLongJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetLongArray().ToArray())
.ToArray();
}
static public char[][] GetCharJaggedArray(int N) {
return Enumerable.Repeat(0, N)
.Select(s => GetStr().ToCharArray())
.ToArray();
}
static public double[][] GetDoubleJaggedArray(int N) {
return Enumerable.Repeat(0, N).Select(s => GetDoubleArray()).ToArray();
}
static public void WriteObjects<T>(IReadOnlyCollection<T> values) {
var array = values.ToArray();
var num = array.Length;
if (num == 0)
return;
Console.Write(array[0]);
for (int i = 1; i < num; i++) {
Console.Write(" " + array[i]);
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
static void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d,
out X e, out Y f) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
f = cv<Y>(ar[5]);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 1,707
| 15
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC122_20200406C.Input;
namespace ABC122_20200406C {
static class Input {
private static Func<string, T[]>
Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray();
private static Func<string, T> Convert<T>() {
Type t = typeof(T);
if (t == typeof(string))
return _ => (T)(object)_;
if (t == typeof(int))
return _ => (T)(object) int.Parse(_);
if (t == typeof(long))
return _ => (T)(object) long.Parse(_);
if (t == typeof(double))
return _ => (T)(object) double.Parse(_);
if (t == typeof(string[]))
return _ => (T)(object)_.Split(' ');
if (t == typeof(int[]))
return _ => (T)(object)Cast<int>()(_);
if (t == typeof(long[]))
return _ => (T)(object)Cast<long>()(_);
if (t == typeof(double[]))
return _ => (T)(object)Cast<double>()(_);
throw new NotSupportedException(t + "is not supported.");
}
private static T Convert<T>(string s) => Convert<T>()(s);
private static string String() => Console.ReadLine();
private static string[] String(long rowNumber) =>
new bool [rowNumber].Select(_ => String()).ToArray();
public static void Cin<T>(out T a) => a = Convert<T>(String());
public static void Cin<T1, T2>(out T1 a1, out T2 a2) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
}
public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
}
public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
}
public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4, out T5 a5) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
}
public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2,
out T3 a3, out T4 a4,
out T5 a5, out T6 a6) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
set(v[5], out a6);
}
private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s);
public static void
Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray();
public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) {
l1 = new T1[n];
l2 = new T2[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i]);
}
public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2,
out T3[] l3) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i]);
}
public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2,
out T3[] l3, out T4[] l4) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
l4 = new T4[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i], out l4[i]);
}
public static void Cin<T>(out T[] a) => a = Convert<T[]>(String());
public static void Cin<T>(long h, out T[][] map) => map =
String(h).Select(Convert<T[]>()).ToArray();
}
class Program {
public static void Main(string[] args) {
StreamWriter streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
new Solver().Solve();
Console.Out.Flush();
}
public static void Debug() { new Solver().Solve(); }
}
class Solver {
public void Solve() {
int N;
long[] x, y, h;
Cin(out N);
Cin(N, out x, out y, out h);
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
// hใ0ไปฅๅคใฎใในใใ้ซใใๆฑใใ
long H = 0;
for (int i = 0; i < N; i++) {
if (h[i] == 0)
continue;
H = h[i] + Math.Abs(x[i] - cx) + Math.Abs(y[i] - cy);
}
//็็พใใฆใใใใใ
bool dame = false;
for (int i = 0; i < N; i++) {
if (H - (Math.Abs(x[i] - cx) + Math.Abs(y[i] - cy)) != h[i]) {
dame = true;
}
}
if (dame)
continue;
Console.WriteLine("" + cx + " " + cy + " " + H);
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC122_20200406C.Input;
namespace ABC122_20200406C {
static class Input {
private static Func<string, T[]>
Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToArray();
private static Func<string, T> Convert<T>() {
Type t = typeof(T);
if (t == typeof(string))
return _ => (T)(object)_;
if (t == typeof(int))
return _ => (T)(object) int.Parse(_);
if (t == typeof(long))
return _ => (T)(object) long.Parse(_);
if (t == typeof(double))
return _ => (T)(object) double.Parse(_);
if (t == typeof(string[]))
return _ => (T)(object)_.Split(' ');
if (t == typeof(int[]))
return _ => (T)(object)Cast<int>()(_);
if (t == typeof(long[]))
return _ => (T)(object)Cast<long>()(_);
if (t == typeof(double[]))
return _ => (T)(object)Cast<double>()(_);
throw new NotSupportedException(t + "is not supported.");
}
private static T Convert<T>(string s) => Convert<T>()(s);
private static string String() => Console.ReadLine();
private static string[] String(long rowNumber) =>
new bool [rowNumber].Select(_ => String()).ToArray();
public static void Cin<T>(out T a) => a = Convert<T>(String());
public static void Cin<T1, T2>(out T1 a1, out T2 a2) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
}
public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
}
public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
}
public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4, out T5 a5) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
}
public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2,
out T3 a3, out T4 a4,
out T5 a5, out T6 a6) {
var v = String().Split(' ');
set(v[0], out a1);
set(v[1], out a2);
set(v[2], out a3);
set(v[3], out a4);
set(v[4], out a5);
set(v[5], out a6);
}
private static void set<T1>(string s, out T1 o1) => o1 = Convert<T1>(s);
public static void
Cin<T>(long n, out T[] l) => l = String(n).Select(Convert<T>()).ToArray();
public static void Cin<T1, T2>(long n, out T1[] l1, out T2[] l2) {
l1 = new T1[n];
l2 = new T2[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i]);
}
public static void Cin<T1, T2, T3>(long n, out T1[] l1, out T2[] l2,
out T3[] l3) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i]);
}
public static void Cin<T1, T2, T3, T4>(long n, out T1[] l1, out T2[] l2,
out T3[] l3, out T4[] l4) {
l1 = new T1[n];
l2 = new T2[n];
l3 = new T3[n];
l4 = new T4[n];
for (int i = 0; i < n; i++)
Cin(out l1[i], out l2[i], out l3[i], out l4[i]);
}
public static void Cin<T>(out T[] a) => a = Convert<T[]>(String());
public static void Cin<T>(long h, out T[][] map) => map =
String(h).Select(Convert<T[]>()).ToArray();
}
class Program {
public static void Main(string[] args) {
StreamWriter streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
new Solver().Solve();
Console.Out.Flush();
}
public static void Debug() { new Solver().Solve(); }
}
class Solver {
public void Solve() {
int N;
long[] x, y, h;
Cin(out N);
Cin(N, out x, out y, out h);
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
// hใ0ไปฅๅคใฎใในใใ้ซใใๆฑใใ
long H = 0;
for (int i = 0; i < N; i++) {
if (h[i] == 0)
continue;
H = h[i] + Math.Abs(x[i] - cx) + Math.Abs(y[i] - cy);
}
//็็พใใฆใใใใใ
bool dame = false;
for (int i = 0; i < N; i++) {
if (Math.Max(0, H - Math.Abs(x[i] - cx) - Math.Abs(y[i] - cy)) !=
h[i]) {
dame = true;
}
}
if (dame)
continue;
Console.WriteLine("" + cx + " " + cy + " " + H);
}
}
}
}
}
|
[["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 21], ["-", 0, 57, 15, 16, 31, 16, 12, 23, 0, 24], ["-", 15, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 17, 33]]
| 8
| 1,590
| 9
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class ACCEPTED {
public void Solve() {
var o = Ints;
var N = o[0];
var x = new Tuple<int, int, int>[N];
int y = 0;
for (int i = 0; i < N; ++i) {
var q = Ints;
x[i] = new Tuple<int, int, int>(q[0], q[1], q[2]);
if (q[2] != 0)
y = i;
}
for (int i = 0; i <= 100; ++i) {
for (int j = 0; j <= 100; ++j) {
var h = Abs(i - x[y].Item1) + Abs(j - x[y].Item2) + x[y].Item3;
bool ok = true;
for (int k = 0; k < N; ++k) {
var nh = Abs(i - x[k].Item1) + Abs(j - x[k].Item2) + x[k].Item3;
if (nh != h) {
ok = false;
break;
}
}
if (ok) {
Write(i, j, h);
return;
}
}
}
}
}
public static class Graph {}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const int MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Pow(long i, long N, long MOD = 1000000007) {
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
public static Dictionary<long, int> PrimeFactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public static List<long> DivisorEnumrate(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var ACCEPTED = new ACCEPTED();
ACCEPTED.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] HorizontalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Horizontalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class ACCEPTED {
public void Solve() {
var o = Ints;
var N = o[0];
var x = new Tuple<int, int, int>[N];
int y = 0;
for (int i = 0; i < N; ++i) {
var q = Ints;
x[i] = new Tuple<int, int, int>(q[0], q[1], q[2]);
if (q[2] != 0)
y = i;
}
for (int i = 0; i <= 100; ++i) {
for (int j = 0; j <= 100; ++j) {
var h = Abs(i - x[y].Item1) + Abs(j - x[y].Item2) + x[y].Item3;
bool ok = true;
for (int k = 0; k < N; ++k) {
var nh = Abs(i - x[k].Item1) + Abs(j - x[k].Item2);
nh = Max(h - nh, 0);
if (nh != x[k].Item3) {
ok = false;
break;
}
}
if (ok) {
Write(i, j, h);
return;
}
}
}
}
}
public static class Graph {}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const int MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Pow(long i, long N, long MOD = 1000000007) {
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
public static Dictionary<long, int> PrimeFactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public static List<long> DivisorEnumrate(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var ACCEPTED = new ACCEPTED();
ACCEPTED.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] HorizontalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Horizontalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 8, 196, 0, 7, 8, 196, 0, 197, 0, 35], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 213, 63, 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], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 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, 79], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 1,284
| 23
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// ๅ
ฅๅ
var n = int.Parse(Console.ReadLine());
int[] x = new int[n];
int[] y = new int[n];
int[] h = new int[n];
for (int i = 0; i < n; i++) {
int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
x[i] = tmp[0];
y[i] = tmp[1];
h[i] = tmp[2];
}
//ๅ
จๆข็ดข
var ansx = 0;
var ansy = 0;
var ansh = 0;
for (int i = 0; i < 101; i++) {
for (int k = 0; k < 101; k++) {
bool flag = true;
var tmp = h[0] + Math.Abs(i - x[0]) + Math.Abs(k - y[0]);
for (int t = 1; t < n; t++) {
if (h[t] > 0 &&
tmp != h[t] + Math.Abs(i - x[t]) + Math.Abs(k - y[t])) {
flag = false;
}
if (h[t] == 0 &&
tmp != h[t] + Math.Abs(i - x[t]) + Math.Abs(k - y[t])) {
flag = false;
}
}
if (flag) {
ansx = i;
ansy = k;
ansh = tmp;
}
}
}
Console.Write("{0} {1} {2}", ansx, ansy, ansh);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// ๅ
ฅๅ
var n = int.Parse(Console.ReadLine());
int[] x = new int[n];
int[] y = new int[n];
int[] h = new int[n];
var s = 0;
for (int i = 0; i < n; i++) {
int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
x[i] = tmp[0];
y[i] = tmp[1];
h[i] = tmp[2];
if (h[i] != 0) {
s = i;
}
}
//ๅ
จๆข็ดข
var ansx = 0;
var ansy = 0;
var ansh = 0;
for (int i = 0; i < 101; i++) {
for (int k = 0; k < 101; k++) {
bool flag = true;
var tmp = h[s] + Math.Abs(i - x[s]) + Math.Abs(k - y[s]);
for (int t = 0; t < n; t++) {
if (h[t] > 0 &&
tmp != h[t] + Math.Abs(i - x[t]) + Math.Abs(k - y[t])) {
flag = false;
}
if (h[t] == 0 && tmp > Math.Abs(i - x[t]) + Math.Abs(k - y[t])) {
flag = false;
}
}
if (flag) {
ansx = i;
ansy = k;
ansh = tmp;
}
}
}
Console.WriteLine("{0} {1} {2}", ansx, ansy, ansh);
return;
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 7, 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, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 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, 7, 8, 196, 0, 46], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["-", 12, 16, 12, 16, 31, 16, 31, 204, 205, 22], ["-", 12, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 12, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 15, 16, 12, 16, 12, 16, 31, 16, 17, 72], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38]]
| 8
| 386
| 39
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;
namespace kyoupuro {
class Point {
public int X { get; set; }
public int Y { get; set; }
public int H { get; set; }
}
class MainClass {
public static void Main() {
var N = NextInt();
var list = new List<Point>();
for (int i = 0; i < N; i++) {
list.Add(new Point() { X = NextInt(), Y = NextInt(), H = NextInt() });
}
list.Sort((a, b) => b.H - a.H);
for (int nowX = 0; nowX <= 100; nowX++) {
for (int nowY = 0; nowY <= 100; nowY++) {
var nowH = Math.Abs(list.First().X - nowX) +
Math.Abs(list.First().Y - nowY) + list.First().H;
if (list.All(point => point.H == nowH - Math.Abs(point.Y - nowY) -
Math.Abs(point.X - nowX))) {
Console.WriteLine($"{nowX} {nowY} {nowH}");
return;
}
}
}
}
}
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
}
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line() { return Console.ReadLine(); }
public static int NextInt() {
while (!enumerator.MoveNext()) {
enumerator = StrArr().AsEnumerable().GetEnumerator();
}
return int.Parse(enumerator.Current);
}
public static long NextLong() {
while (!enumerator.MoveNext()) {
enumerator = StrArr().AsEnumerable().GetEnumerator();
}
return long.Parse(enumerator.Current);
}
public static string[] StrArr() { return Line().Split(' '); }
public static List<int> IntList() {
return StrArr().Select(int.Parse).ToList();
}
public static List<long> LongList() {
return StrArr().Select(long.Parse).ToList();
}
public static void Skip(int line = 1) {
enumerator.Reset();
for (int i = 0; i < line; i++)
Console.ReadLine();
}
public static void Reset() { enumerator.Reset(); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;
namespace kyoupuro {
class Point {
public int X { get; set; }
public int Y { get; set; }
public int H { get; set; }
}
class MainClass {
public static void Main() {
var N = NextInt();
var list = new List<Point>();
for (int i = 0; i < N; i++) {
list.Add(new Point() { X = NextInt(), Y = NextInt(), H = NextInt() });
}
list.Sort((a, b) => b.H - a.H);
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var nowH = Math.Abs(list.First().X - cx) +
Math.Abs(list.First().Y - cy) + list.First().H;
if (list.All(point =>
point.H == Math.Max(0, nowH - Math.Abs(point.Y - cy) -
Math.Abs(point.X - cx)))) {
Console.WriteLine($"{cx} {cy} {nowH}");
return;
}
}
}
}
}
class MyMath {
public static long Gcd(long a, long b) { return b == 0 ? a : Gcd(b, a % b); }
}
class Input {
static IEnumerator<string> enumerator =
new string[] {}.AsEnumerable().GetEnumerator();
public static string Line() { return Console.ReadLine(); }
public static int NextInt() {
while (!enumerator.MoveNext()) {
enumerator = StrArr().AsEnumerable().GetEnumerator();
}
return int.Parse(enumerator.Current);
}
public static long NextLong() {
while (!enumerator.MoveNext()) {
enumerator = StrArr().AsEnumerable().GetEnumerator();
}
return long.Parse(enumerator.Current);
}
public static string[] StrArr() { return Line().Split(' '); }
public static List<int> IntList() {
return StrArr().Select(int.Parse).ToList();
}
public static List<long> LongList() {
return StrArr().Select(long.Parse).ToList();
}
public static void Skip(int line = 1) {
enumerator.Reset();
for (int i = 0; i < line; i++)
Console.ReadLine();
}
public static void Reset() { enumerator.Reset(); }
}
}
|
[["-", 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, 223, 0, 22], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 223, 0, 22], ["-", 31, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 218, 8, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 218, 8, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 218, 8, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 218, 8, 16, 12, 213, 3, 4, 0, 24], ["+", 8, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 218, 8, 16, 12, 213, 3, 4, 0, 21], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["+", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22]]
| 8
| 584
| 31
|
using System;
namespace abc115 {
class MainClass {
public static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var x = new int[n];
var y = new int[n];
var h = new int[n];
for (int i = 0; i < n; i++) {
var xyh = Console.ReadLine().Split();
x[i] = int.Parse(xyh[0]);
y[i] = int.Parse(xyh[1]);
h[i] = int.Parse(xyh[2]);
}
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var ch = m1(cx, cy, x[0], y[0], h[0]);
for (int k = 1; k < n; k++) {
var _ch = m1(cx, cy, x[k], y[k], h[k]);
ch = m2(ch, _ch);
}
if (ch.Item1 == 1) {
Console.WriteLine($"{cx} {cy} {ch.Item2}");
return;
}
}
}
}
static Tuple<int, int> m2(Tuple<int, int> x, Tuple<int, int> y) {
if (x.Item1 == -1)
return x;
if (x.Item1 == 0 && y.Item1 == 0) {
return Tuple.Create(0, Math.Max(x.Item2, y.Item2));
}
if (x.Item1 == 0 && y.Item1 == 1) {
if (x.Item2 <= y.Item2) {
return y;
} else {
return Tuple.Create(-1, 0);
}
}
if (x.Item1 == 1 && y.Item1 == 0) {
if (y.Item2 <= x.Item2) {
return x;
} else {
return Tuple.Create(-1, 0);
}
}
if (x.Item1 == 1 && y.Item1 == 1) {
if (x.Item2 == y.Item2) {
return x;
} else {
return Tuple.Create(-1, 0);
}
}
throw new Exception();
}
static Tuple<int, int> m1(int cx, int cy, int x, int y, int h) {
var ch = h + Math.Abs(cx - x) + Math.Abs(cy - y);
if (h == 0) {
return Tuple.Create(0, ch);
} else {
return Tuple.Create(1, ch);
}
}
}
}
|
using System;
namespace abc115 {
class MainClass {
public static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var x = new int[n];
var y = new int[n];
var h = new int[n];
for (int i = 0; i < n; i++) {
var xyh = Console.ReadLine().Split();
x[i] = int.Parse(xyh[0]);
y[i] = int.Parse(xyh[1]);
h[i] = int.Parse(xyh[2]);
}
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var ch = m1(cx, cy, x[0], y[0], h[0]);
for (int k = 1; k < n; k++) {
var _ch = m1(cx, cy, x[k], y[k], h[k]);
ch = m2(ch, _ch);
if (ch.Item1 == -1)
break;
}
if (ch.Item1 == 1) {
Console.WriteLine($"{cx} {cy} {ch.Item2}");
return;
}
}
}
}
static Tuple<int, int> m2(Tuple<int, int> x, Tuple<int, int> y) {
if (x.Item1 == -1)
return x;
if (x.Item1 == 0 && y.Item1 == 0) {
return Tuple.Create(0, Math.Min(x.Item2, y.Item2));
}
if (x.Item1 == 0 && y.Item1 == 1) {
if (y.Item2 <= x.Item2) {
return y;
} else {
return Tuple.Create(-1, 0);
}
}
if (x.Item1 == 1 && y.Item1 == 0) {
if (x.Item2 <= y.Item2) {
return x;
} else {
return Tuple.Create(-1, 0);
}
}
if (x.Item1 == 1 && y.Item1 == 1) {
if (x.Item2 == y.Item2) {
return x;
} else {
return Tuple.Create(-1, 0);
}
}
throw new Exception();
}
static Tuple<int, int> m1(int cx, int cy, int x, int y, int h) {
var ch = h + Math.Abs(cx - x) + Math.Abs(cy - y);
if (h == 0) {
return Tuple.Create(0, ch);
} else {
return Tuple.Create(1, ch);
}
}
}
}
|
[["+", 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, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 93, 0, 35], ["-", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 213, 63, 214, 141, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["-", 64, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 214, 205, 22]]
| 8
| 575
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var xyh = new Tuple<int, int, int>[N];
Tuple<int, int, int> data = null;
for (int i = 0; i < N; i++) {
xyh[i] = Tuple.Create(sc.ReadInt(), sc.ReadInt(), sc.ReadInt());
if (xyh[i].Item3 > 0) {
data = xyh[i];
}
}
for (int cx = 0; cx < 101; cx++) {
for (int cy = 0; cy < 101; cy++) {
var flag = true;
var H =
data.Item3 + Math.Abs(data.Item1 - cx) + Math.Abs(data.Item2 - cy);
for (int i = 0; i < N; i++) {
var x = xyh[i].Item1;
var y = xyh[i].Item2;
var h = xyh[i].Item3;
if (H != h + Math.Abs(x - cx) + Math.Abs(y - cy)) {
flag = false;
break;
}
}
if (flag) {
Console.WriteLine("" + cx + " " + cy + " " + H);
return;
}
}
}
}
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 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;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadInt();
var xyh = new Tuple<int, int, int>[N];
Tuple<int, int, int> data = null;
for (int i = 0; i < N; i++) {
xyh[i] = Tuple.Create(sc.ReadInt(), sc.ReadInt(), sc.ReadInt());
if (xyh[i].Item3 > 0) {
data = xyh[i];
}
}
for (int cx = 0; cx < 101; cx++) {
for (int cy = 0; cy < 101; cy++) {
var flag = true;
var H =
data.Item3 + Math.Abs(data.Item1 - cx) + Math.Abs(data.Item2 - cy);
for (int i = 0; i < N; i++) {
var x = xyh[i].Item1;
var y = xyh[i].Item2;
var h = xyh[i].Item3;
if (h != Math.Max(H - Math.Abs(x - cx) - Math.Abs(y - cy), 0)) {
flag = false;
break;
}
}
if (flag) {
Console.WriteLine("" + cx + " " + cy + " " + H);
return;
}
}
}
}
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 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;
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 57, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 818
| 15
|
using System;
using System.Linq;
class C {
static void Main() {
var n = int.Parse(Console.ReadLine());
var ps =
new int [n]
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
for (var i = 0; i <= 100; i++)
for (var j = 0; j <= 100; j++) {
var p0 = ps.First(p => p[2] != 0);
var h = Math.Abs(i - p0[0]) + Math.Abs(j - p0[1]) + p0[2];
if (ps.All(p => h == Math.Abs(i - p[0]) + Math.Abs(j - p[1]) + p[2])) {
Console.WriteLine($"{i} {j} {h}");
return;
}
}
}
}
|
using System;
using System.Linq;
class C {
static void Main() {
var n = int.Parse(Console.ReadLine());
var ps =
new int [n]
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
for (var i = 0; i <= 100; i++)
for (var j = 0; j <= 100; j++) {
var p0 = ps.First(p => p[2] != 0);
var h = Math.Abs(i - p0[0]) + Math.Abs(j - p0[1]) + p0[2];
if (ps.All(p => p[2] ==
Math.Max(h - Math.Abs(i - p[0]) - Math.Abs(j - p[1]),
0))) {
Console.WriteLine($"{i} {j} {h}");
return;
}
}
}
}
|
[["-", 3, 4, 0, 28, 0, 218, 8, 16, 31, 22], ["+", 0, 28, 0, 218, 8, 16, 31, 204, 205, 22], ["+", 0, 218, 8, 16, 31, 204, 206, 207, 0, 70], ["+", 8, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 218, 8, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 218, 8, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 218, 8, 16, 12, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["-", 0, 218, 8, 16, 12, 16, 31, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 28, 0, 218, 8, 16, 12, 16, 17, 72], ["-", 0, 218, 8, 16, 12, 16, 12, 204, 205, 22], ["-", 8, 16, 12, 16, 12, 204, 206, 207, 0, 70], ["-", 12, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 8, 16, 12, 16, 12, 204, 206, 207, 0, 73], ["+", 0, 218, 8, 16, 12, 213, 3, 4, 0, 21], ["+", 8, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 218, 8, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 214
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var xyh = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
xyh[i] = new Tuple<int, int, int>(temp[0], temp[1], temp[2]);
}
var first = xyh.First(t => t.Item3 >= 1);
if (n == 1) {
Console.WriteLine($"{first.Item1} {first.Item2} {first.Item3}");
return;
}
var ans = new Tuple<int, int, int>(0, 0, 0);
for (int x = 0; x < 101; x++) {
for (int y = 0; y < 101; y++) {
int h =
first.Item3 + Math.Abs(first.Item1 - x) + Math.Abs(first.Item2 - y);
bool ok = true;
for (int i = 0; i < n; i++) {
if (xyh[i].Item3 == 0) {
continue;
}
int h2 = xyh[i].Item3 + Math.Abs(xyh[i].Item1 - x) +
Math.Abs(xyh[i].Item2 - y);
if (h != h2) {
ok = false;
break;
}
}
if (ok) {
if (h > ans.Item3) {
ans = new Tuple<int, int, int>(x, y, h);
}
}
}
}
Console.WriteLine($"{ans.Item1} {ans.Item2} {ans.Item3}");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder {
public class Program {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var xyh = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
xyh[i] = new Tuple<int, int, int>(temp[0], temp[1], temp[2]);
}
var enables = xyh.Where(t => t.Item3 >= 1).ToArray();
var first = enables[0];
if (enables.Count() == 1) {
Console.WriteLine($"{first.Item1} {first.Item2} {first.Item3}");
return;
}
var ans = new Tuple<int, int, int>(0, 0, 0);
for (int x = 0; x < 101; x++) {
for (int y = 0; y < 101; y++) {
int h =
first.Item3 + Math.Abs(first.Item1 - x) + Math.Abs(first.Item2 - y);
bool ok = true;
for (int i = 0; i < n; i++) {
if (xyh[i].Item3 == 0) {
continue;
}
int h2 = xyh[i].Item3 + Math.Abs(xyh[i].Item1 - x) +
Math.Abs(xyh[i].Item2 - y);
if (h != h2) {
ok = false;
break;
}
}
if (ok) {
if (h > ans.Item3) {
ans = new Tuple<int, int, int>(x, y, h);
}
}
}
}
Console.WriteLine($"{ans.Item1} {ans.Item2} {ans.Item3}");
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 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, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25]]
| 8
| 431
| 22
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;
class Program {
static void Main(string[] args) { solve(); }
static Scanner cin;
static int N;
static int[] X;
static int[] Y;
static int[] h;
static void input() {
cin = new Scanner();
N = cin.nextInt();
X = new int[N];
Y = new int[N];
h = new int[N];
for (int i = 0; i < N; i++) {
X[i] = cin.nextInt();
Y[i] = cin.nextInt();
h[i] = cin.nextInt();
}
}
static void solve() {
input();
int v = 0;
for (int i = 0; i < N; i++) {
if (h[i] != 0) {
v = i;
break;
}
}
for (int y = 0; y <= 100; y++)
for (int x = 0; x <= 100; x++) {
int H = Abs(X[v] - x) + Abs(Y[v] - y) + h[v];
if (H <= 0)
continue;
bool isOK = true;
for (int i = 1; i < N; i++) {
if (H != Abs(x - X[i]) + Abs(y - Y[i]) + h[i]) {
isOK = false;
break;
}
}
if (isOK) {
WriteLine($"{x} {y} {H}");
}
}
}
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[] ArrayDounble(int N, int add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using System.Text;
class Program {
static void Main(string[] args) { solve(); }
static Scanner cin;
static int N;
static int[] X;
static int[] Y;
static int[] h;
static void input() {
cin = new Scanner();
N = cin.nextInt();
X = new int[N];
Y = new int[N];
h = new int[N];
for (int i = 0; i < N; i++) {
X[i] = cin.nextInt();
Y[i] = cin.nextInt();
h[i] = cin.nextInt();
}
}
static void solve() {
input();
int v = 0;
for (int i = 0; i < N; i++) {
if (h[i] != 0) {
v = i;
break;
}
}
for (int y = 0; y <= 100; y++)
for (int x = 0; x <= 100; x++) {
int H = Abs(X[v] - x) + Abs(Y[v] - y) + h[v];
if (H <= 0)
continue;
bool isOK = true;
for (int i = 0; i < N; i++) {
int height = Max(H - Abs(x - X[i]) - Abs(y - Y[i]), 0);
if (h[i] != height) {
isOK = false;
break;
}
}
if (isOK) {
WriteLine($"{x} {y} {H}");
}
}
}
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[] ArrayDounble(int N, int add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 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, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 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], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 718
| 20
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace ABC112C {
class Program {
static void Solve(Input input) {
var n = input.NextInt();
var x = new int[n];
var y = new int[n];
var h = new int[n];
for (int i = 0; i < n; i++) {
x[i] = input.NextInt();
y[i] = input.NextInt();
h[i] = input.NextInt();
}
var v = Array.IndexOf(h, h.First(z => z != 0));
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var hh = h[v] + Math.Abs(x[v] - cx) + Math.Abs(y[v] - cy);
if (hh <= 0)
continue;
bool failed = false;
for (int i = 0; i < n; i++) {
var hhh =
Math.Max(h[i] + Math.Abs(x[i] - cx) + Math.Abs(y[i] - cy), 0);
if (hhh != hh) {
failed = true;
break;
}
}
if (!failed) {
Console.WriteLine($"{cx} {cy} {hh}");
return;
}
}
}
Console.WriteLine("Unresolved");
}
#region Main
public static void Main(string[] args) {
// ๅบๅใๅฐใชใใจใใฏใใใใปใใใใๆนใๆ้ใใใใใใฉ
// ใใฎๅ ดๅใฏๅบๅใใใใซใใใฏใซใชใฃใฆใใชใใฎใงใใพใ่ฏใใจใใ
var needsFlushOutput = true;
if (needsFlushOutput) {
// ็ดฐใใๅบๅใใชใใใใซใใ
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// ้ๅธธใฏๅผๆฐ็กใใงใใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
var input = new Input();
// ไปฎๆณ็ใซๆจๆบๅ
ฅๅใใปใใใใ
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
#endregion
#region Competitive Template
#pragma warning disable CS0414
static readonly int MOD = (int)1e9 + 7;
#pragma warning restore CS0414
class Input {
// ๅคใชๆน่กใณใผใใใใพใซๆททใใฃใฆใใใฎใงใไธๅฟใปใใฌใผใๆๅฎใใ
// ในใใผในๅ็ฌๆๅฎใฎๆนใใใกใใๆฉใ
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// ็นๅฎใฎใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// ๅ
้จqueueใซๅ
ฅๅใใใฎๅคใsplitใใฆๆ ผ็ดใใ
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// ๆฌกใฎstringใไธใค่ชญใฟ่พผใ
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// ๆๅฎๅๆฐqueueใซใใพใใพใงenqueueใ็ถใใ
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// nๅใฎ่ฆ็ด ใparseใใฆใใใใใใซoffsetใaddใใ้
ๅใ่ฟใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vใงfillใใใT[d1][d2]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vใงfillใใใT[d1][d2][d3]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace ABC112C {
class Program {
static void Solve(Input input) {
var n = input.NextInt();
var x = new int[n];
var y = new int[n];
var h = new int[n];
for (int i = 0; i < n; i++) {
x[i] = input.NextInt();
y[i] = input.NextInt();
h[i] = input.NextInt();
}
var v = Array.IndexOf(h, h.First(z => z != 0));
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var hh = h[v] + Math.Abs(x[v] - cx) + Math.Abs(y[v] - cy);
if (hh <= 0)
continue;
bool failed = false;
for (int i = 0; i < n; i++) {
// if (h[i] == 0) continue;
var hhh = Math.Max(hh - Math.Abs(x[i] - cx) - Math.Abs(y[i] - cy), 0);
if (hhh != h[i]) {
failed = true;
break;
}
}
if (!failed) {
Console.WriteLine($"{cx} {cy} {hh}");
return;
}
}
}
Console.WriteLine("Unresolved");
}
#region Main
public static void Main(string[] args) {
// ๅบๅใๅฐใชใใจใใฏใใใใปใใใใๆนใๆ้ใใใใใใฉ
// ใใฎๅ ดๅใฏๅบๅใใใใซใใใฏใซใชใฃใฆใใชใใฎใงใใพใ่ฏใใจใใ
var needsFlushOutput = true;
if (needsFlushOutput) {
// ็ดฐใใๅบๅใใชใใใใซใใ
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// ้ๅธธใฏๅผๆฐ็กใใงใใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
var input = new Input();
// ไปฎๆณ็ใซๆจๆบๅ
ฅๅใใปใใใใ
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
#endregion
#region Competitive Template
#pragma warning disable CS0414
static readonly int MOD = (int)1e9 + 7;
#pragma warning restore CS0414
class Input {
// ๅคใชๆน่กใณใผใใใใพใซๆททใใฃใฆใใใฎใงใไธๅฟใปใใฌใผใๆๅฎใใ
// ในใใผในๅ็ฌๆๅฎใฎๆนใใใกใใๆฉใ
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// ็นๅฎใฎใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// ๅ
้จqueueใซๅ
ฅๅใใใฎๅคใsplitใใฆๆ ผ็ดใใ
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// ๆฌกใฎstringใไธใค่ชญใฟ่พผใ
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// ๆๅฎๅๆฐqueueใซใใพใใพใงenqueueใ็ถใใ
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// nๅใฎ่ฆ็ด ใparseใใฆใใใใใใซoffsetใaddใใ้
ๅใ่ฟใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vใงfillใใใT[d1][d2]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vใงfillใใใT[d1][d2][d3]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
[["-", 0, 28, 0, 16, 31, 16, 31, 204, 205, 22], ["-", 0, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 1,418
| 14
|
using System;
using System.Linq;
namespace ABC112_C {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var list = new Model[N];
for (int i = 0; i < N; i++) {
var line = Console.ReadLine().Split().Select(long.Parse).ToArray();
list[i] = new Model() { x = line[0], y = line[1], h = line[2] };
}
if (N == 1) {
Console.WriteLine($"{list[0].x} {list[0].y} {list[0].h}");
return;
}
var ans = new Model();
for (int x = 0; x <= 100; x++) {
for (int y = 0; y <= 100; y++) {
var first = list[0];
var temp = new Model() { x = x, y = y,
h = first.h + (Math.Abs(x - first.x) +
Math.Abs(y - first.y)) };
var flag = true;
for (int i = 1; i < N; i++) {
var now = list[i];
if (now.h + Math.Abs(x - now.x) + Math.Abs(y - now.y) != temp.h) {
flag = false;
break;
}
}
if (!flag)
continue;
if (ans.h <= temp.h) {
ans = temp;
}
}
}
Console.WriteLine($"{ans.x} {ans.y} {ans.h}");
}
class Model {
public long x { get; set; }
public long y { get; set; }
public long h { get; set; }
}
}
}
|
using System;
using System.Linq;
namespace ABC112_C {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var list = new Model[N];
for (int i = 0; i < N; i++) {
var line = Console.ReadLine().Split().Select(long.Parse).ToArray();
list[i] = new Model() { x = line[0], y = line[1], h = line[2] };
}
if (N == 1) {
Console.WriteLine($"{list[0].x} {list[0].y} {list[0].h}");
return;
}
list = list.OrderByDescending(n => n.h).ToArray();
var ans = new Model();
for (int x = 0; x <= 100; x++) {
for (int y = 0; y <= 100; y++) {
var first = list[0];
var temp = new Model() { x = x, y = y,
h = first.h + (Math.Abs(x - first.x) +
Math.Abs(y - first.y)) };
var flag = true;
for (int i = 1; i < N; i++) {
var now = list[i];
if (Math.Max(temp.h - Math.Abs(x - now.x) - Math.Abs(y - now.y), 0) !=
now.h) {
flag = false;
break;
}
}
if (!flag)
continue;
if (ans.h <= temp.h) {
ans = temp;
}
}
}
Console.WriteLine($"{ans.x} {ans.y} {ans.h}");
}
class Model {
public long x { get; set; }
public long y { get; set; }
public long h { get; set; }
}
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 218, 54, 219, 0, 220, 141, 22], ["+", 205, 213, 3, 4, 0, 28, 0, 218, 0, 221], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 0, 131], ["+", 3, 4, 0, 28, 0, 218, 8, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 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, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["-", 15, 16, 31, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 214, 0, 131], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 21], ["+", 15, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22]]
| 8
| 409
| 32
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ABC112.Cin;
using static ABC112.Util;
using static System.Console;
using static System.Math;
using System.Collections;
#if DEBUG
using System.Diagnostics;
#endif
/// <summary>
/// https://atcoder.jp/contests/abc112/tasks
/// </summary>
namespace ABC112 {
class Program {
static void Main(string[] args) {
START:
// ProgrammingEducation();
// TimeLimitExceeded();
Pyramid();
// Partition();
#if DEBUG
goto START;
#endif
}
private static void Partition() {
long N = ReadLong();
long M = ReadLong();
int[] divisorList = GetDivisor((int)M);
ReverseSort(divisorList);
long ans = 0;
foreach (int div in divisorList) {
if (M / div >= N) {
ans = div;
break;
}
}
WriteLine(ans);
}
private static void Pyramid() {
long N = ReadLong();
long[][] table = ReadLongTable(N);
long si = -1;
foreach (long[] info in table) {
if (info[2] > 0) {
si = info[2];
break;
}
}
long resx = -1, resy = -1, resh = -1;
foreach (int cx in Range(101)) {
foreach (int cy in Range(101)) {
long h = table[si][2] + Abs(table[si][0] - cx) + Abs(table[si][1] - cy);
foreach (long[] info in table) {
if (info[2] > 0 &&
h != Abs(info[0] - cx) + Abs(info[1] - cy) + info[2]) {
goto CONTINUE;
}
if (info[2] == 0 && h > Abs(info[0] - cx) + Abs(info[1] - cy)) {
goto CONTINUE;
}
}
resx = cx;
resy = cy;
resh = h;
goto BREAK;
CONTINUE:;
}
}
BREAK:
string ans = string.Format("{0} {1} {2}", resx, resy, resh);
WriteLine(ans);
}
static void TimeLimitExceeded() {
int N = ReadInt();
int T = ReadInt();
int[][] C = ReadIntTable(N);
long ans = long.MaxValue;
foreach (var c in C) {
if (c[1] > T)
continue;
ChMin(ref ans, c[0]);
}
if (ans == long.MaxValue) {
WriteLine("TLE");
} else {
WriteLine(ans);
}
}
private static void ProgrammingEducation() {
int N = ReadInt();
if (N == 1) {
WriteLine("Hello World");
} else {
int A = ReadInt();
int B = ReadInt();
int ans = A + B;
WriteLine(ans);
}
}
}
#region ToolBox
public static class Cin {
static string[] Tokens { get; set; }
static int Ptr { get; set; }
public static string Next() {
if (Tokens == null || Tokens.Length <= Ptr) {
Tokens = Console.ReadLine().Split(' ');
Ptr = 0;
}
return Tokens[Ptr++];
}
public static int ReadInt() { return int.Parse(Next()); }
public static long ReadLong() { return long.Parse(Next()); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static int[][] ReadIntTable(int n) {
Tokens = null;
int[][] ret = new int [n][];
for (int i = 0; i < n; i++) {
ret[i] = ReadIntArray();
}
return ret;
}
public static long[][] ReadLongTable(long n) {
Tokens = null;
long[][] ret = new long [n][];
for (long i = 0; i < n; i++) {
ret[i] = ReadLongArray();
}
return ret;
}
public static string ReadString() {
Tokens = null;
return Console.ReadLine();
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใintใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().ToArray(),
c => int.Parse(c.ToString()));
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใboolใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
Tokens = null;
return Console.ReadLine().Select(c => c == '1').ToArray();
}
}
/// <summary>
/// ใฆใผใใฃใชใใฃใผ
/// </summary>
public static class Util {
// 10^17
public static readonly long INF = (long)1e17;
public static IEnumerable<int> Range(int end) {
for (int i = 0; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end) {
for (int i = from; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end, int step) {
for (int i = from; i < end; i += step) {
yield return i;
}
}
/// <summary>
/// ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// ้้ ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] ReverseSort<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyใซใใใใใชใใค
/// ex) 5.Times(i => Console.WriteLine(i));
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
/// <summary>
/// ๅผๆฐaใจๅผๆฐbใฎๅคใๅ
ฅใๆฟใใพใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
/// <summary>
/// Console.WriteLineใฎ่ชๅใใฉใใทใฅใใใชใใใใซใใ
/// </summary>
public static void DontAutoFlush() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
/// <summary>
/// ๅ
้ ญใจๆซๅฐพใซ่ฆ็ด ใๅขใใใๆฐใใ้
ๅใ่ฟใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] AddHeadAndTail<T>(T[] array) {
int len = array.Length;
T[] res = new T[len + 2];
Array.Copy(array, 0, res, 1, len);
return res;
}
/// <summary>
/// ๆ้ ใฝใผใๆธใฟใฎ้
ๅใ2ๅๆข็ดขใใพใใ
/// ่ฆ็ด ใ่ฆใคใใใชใใฃใๅ ดๅใฏnใใๅคงใใๆฐๅคใฎไธญใงๆๅฐใฎๆฐๅคใฎใคใณใใใฏในใ่ฟใใ
/// </summary>
/// <param name="array"></param>
/// <param name="n"></param>
/// <returns></returns>
public static int BinarySearch(long[] array, long n) {
int left = 0;
int right = array.Length - 1;
while (left <= right) {
int mid = (right - left) / 2 + left;
if (array[mid] == n) {
return mid;
} else if (n < array[mid]) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return left;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static int[] GetDivisor(int n) {
double sqrt = Math.Sqrt(n);
List<int> divisor = new List<int>();
for (int i = 1; i <= sqrt; i++) {
if (n % i == 0) {
divisor.Add(i);
int tmp = n / i;
if (tmp != i) {
divisor.Add(tmp);
}
}
}
return Sort(divisor.ToArray());
}
public static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
public static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
public static void Deconstruct<T>(this T[] items, out T t0) {
t0 = items.Length > 0 ? items[0] : default(T);
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1) {
if (items.Length < 2)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2) {
if (items.Length < 3)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2, out T t3) {
if (items.Length < 4)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
t3 = items[3];
}
public static void ArrayInitialize<T>(T[,] array, T value) {
int len0 = array.GetLength(0);
int len1 = array.GetLength(1);
for (int i = 0; i < len0; i++) {
for (int j = 0; j < len1; j++) {
array[i, j] = value;
}
}
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public readonly static int MOD = 1000000007;
public static void ModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long minValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (n < minValue) {
min = x;
}
}
return min;
}
public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long maxValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (maxValue < n) {
min = x;
}
}
return min;
}
#if DEBUG
static void SampleGenerator() {
int A = 1000;
int B = 1000;
int Q = 1000;
Random r = new Random();
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("{0} {1} {2}", A, B, Q));
A.Times(a => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
B.Times(b => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Q.Times(q => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Debug.WriteLine(sb.ToString());
}
#endif
}
/// <summary>
/// HashSetใซTupleใๅ
ฅใใๆใฎใ็ญๅคๆงๅคๅฎๆนๆณใฎๆๅฎใซไฝฟใใพใใ
/// HashSetใฎใณใณในใใฉใฏใฟใซๆธกใใฆไฝฟใใพใใ
/// EqualsใจGetHashCodeใๆไพใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// UnionFindTree
/// </summary>
public class UnionFindTree {
int[] Node;
public UnionFindTree(int N) {
Node = new int[N];
for (int i = 0; i < N; i++) {
Node[i] = -1;
}
}
public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); }
public bool Merge(int x, int y) {
int xr = GetRoot(x);
int yr = GetRoot(y);
if (xr == yr)
return false;
// xใใๅคงใใชใฐใซใผใใ็คบใใใใซSwapใใ๏ผๅคใๅฐใใๆนใๅคงใใชใฐใซใผใ๏ผ
if (Node[xr] > Node[yr])
Swap(ref xr, ref yr);
// ใฐใซใผใใฎๆฐใๅ็ฎใใ
Node[xr] += Node[yr];
// ๆ นใๅผตใๆฟใใ
Node[yr] = xr;
return true;
}
public int Size(int x) { return -Node[GetRoot(x)]; }
public int GetRoot(int n) {
if (Node[n] < 0) {
return n;
} else {
// ๆ นใๅผตใใชใใใ
Node[n] = GetRoot(Node[n]);
return Node[n];
}
}
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T> {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
return _comparison(x, y);
// if (_comparison != null) return _comparison(x, y);
// return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ABC112.Cin;
using static ABC112.Util;
using static System.Console;
using static System.Math;
using System.Collections;
#if DEBUG
using System.Diagnostics;
#endif
/// <summary>
/// https://atcoder.jp/contests/abc112/tasks
/// </summary>
namespace ABC112 {
class Program {
static void Main(string[] args) {
START:
// ProgrammingEducation();
// TimeLimitExceeded();
Pyramid();
// Partition();
#if DEBUG
goto START;
#endif
}
private static void Partition() {
long N = ReadLong();
long M = ReadLong();
int[] divisorList = GetDivisor((int)M);
ReverseSort(divisorList);
long ans = 0;
foreach (int div in divisorList) {
if (M / div >= N) {
ans = div;
break;
}
}
WriteLine(ans);
}
private static void Pyramid() {
long N = ReadLong();
long[][] table = ReadLongTable(N);
long si = -1;
foreach (int i in Range((int)N)) {
if (table[i][2] > 0) {
si = i;
break;
}
}
long resx = -1, resy = -1, resh = -1;
foreach (int cx in Range(101)) {
foreach (int cy in Range(101)) {
long h = table[si][2] + Abs(table[si][0] - cx) + Abs(table[si][1] - cy);
foreach (long[] info in table) {
if (info[2] > 0 &&
h != Abs(info[0] - cx) + Abs(info[1] - cy) + info[2]) {
goto CONTINUE;
}
if (info[2] == 0 && h > Abs(info[0] - cx) + Abs(info[1] - cy)) {
goto CONTINUE;
}
}
resx = cx;
resy = cy;
resh = h;
goto BREAK;
CONTINUE:;
}
}
BREAK:
string ans = string.Format("{0} {1} {2}", resx, resy, resh);
WriteLine(ans);
}
static void TimeLimitExceeded() {
int N = ReadInt();
int T = ReadInt();
int[][] C = ReadIntTable(N);
long ans = long.MaxValue;
foreach (var c in C) {
if (c[1] > T)
continue;
ChMin(ref ans, c[0]);
}
if (ans == long.MaxValue) {
WriteLine("TLE");
} else {
WriteLine(ans);
}
}
private static void ProgrammingEducation() {
int N = ReadInt();
if (N == 1) {
WriteLine("Hello World");
} else {
int A = ReadInt();
int B = ReadInt();
int ans = A + B;
WriteLine(ans);
}
}
}
#region ToolBox
public static class Cin {
static string[] Tokens { get; set; }
static int Ptr { get; set; }
public static string Next() {
if (Tokens == null || Tokens.Length <= Ptr) {
Tokens = Console.ReadLine().Split(' ');
Ptr = 0;
}
return Tokens[Ptr++];
}
public static int ReadInt() { return int.Parse(Next()); }
public static long ReadLong() { return long.Parse(Next()); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static int[][] ReadIntTable(int n) {
Tokens = null;
int[][] ret = new int [n][];
for (int i = 0; i < n; i++) {
ret[i] = ReadIntArray();
}
return ret;
}
public static long[][] ReadLongTable(long n) {
Tokens = null;
long[][] ret = new long [n][];
for (long i = 0; i < n; i++) {
ret[i] = ReadLongArray();
}
return ret;
}
public static string ReadString() {
Tokens = null;
return Console.ReadLine();
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใintใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().ToArray(),
c => int.Parse(c.ToString()));
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใboolใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
Tokens = null;
return Console.ReadLine().Select(c => c == '1').ToArray();
}
}
/// <summary>
/// ใฆใผใใฃใชใใฃใผ
/// </summary>
public static class Util {
// 10^17
public static readonly long INF = (long)1e17;
public static IEnumerable<int> Range(int end) {
for (int i = 0; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end) {
for (int i = from; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end, int step) {
for (int i = from; i < end; i += step) {
yield return i;
}
}
/// <summary>
/// ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// ้้ ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] ReverseSort<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyใซใใใใใชใใค
/// ex) 5.Times(i => Console.WriteLine(i));
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
/// <summary>
/// ๅผๆฐaใจๅผๆฐbใฎๅคใๅ
ฅใๆฟใใพใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
/// <summary>
/// Console.WriteLineใฎ่ชๅใใฉใใทใฅใใใชใใใใซใใ
/// </summary>
public static void DontAutoFlush() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
/// <summary>
/// ๅ
้ ญใจๆซๅฐพใซ่ฆ็ด ใๅขใใใๆฐใใ้
ๅใ่ฟใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] AddHeadAndTail<T>(T[] array) {
int len = array.Length;
T[] res = new T[len + 2];
Array.Copy(array, 0, res, 1, len);
return res;
}
/// <summary>
/// ๆ้ ใฝใผใๆธใฟใฎ้
ๅใ2ๅๆข็ดขใใพใใ
/// ่ฆ็ด ใ่ฆใคใใใชใใฃใๅ ดๅใฏnใใๅคงใใๆฐๅคใฎไธญใงๆๅฐใฎๆฐๅคใฎใคใณใใใฏในใ่ฟใใ
/// </summary>
/// <param name="array"></param>
/// <param name="n"></param>
/// <returns></returns>
public static int BinarySearch(long[] array, long n) {
int left = 0;
int right = array.Length - 1;
while (left <= right) {
int mid = (right - left) / 2 + left;
if (array[mid] == n) {
return mid;
} else if (n < array[mid]) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return left;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static int[] GetDivisor(int n) {
double sqrt = Math.Sqrt(n);
List<int> divisor = new List<int>();
for (int i = 1; i <= sqrt; i++) {
if (n % i == 0) {
divisor.Add(i);
int tmp = n / i;
if (tmp != i) {
divisor.Add(tmp);
}
}
}
return Sort(divisor.ToArray());
}
public static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
public static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
public static void Deconstruct<T>(this T[] items, out T t0) {
t0 = items.Length > 0 ? items[0] : default(T);
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1) {
if (items.Length < 2)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2) {
if (items.Length < 3)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2, out T t3) {
if (items.Length < 4)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
t3 = items[3];
}
public static void ArrayInitialize<T>(T[,] array, T value) {
int len0 = array.GetLength(0);
int len1 = array.GetLength(1);
for (int i = 0; i < len0; i++) {
for (int j = 0; j < len1; j++) {
array[i, j] = value;
}
}
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public readonly static int MOD = 1000000007;
public static void ModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long minValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (n < minValue) {
min = x;
}
}
return min;
}
public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long maxValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (maxValue < n) {
min = x;
}
}
return min;
}
#if DEBUG
static void SampleGenerator() {
int A = 1000;
int B = 1000;
int Q = 1000;
Random r = new Random();
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("{0} {1} {2}", A, B, Q));
A.Times(a => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
B.Times(b => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Q.Times(q => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Debug.WriteLine(sb.ToString());
}
#endif
}
/// <summary>
/// HashSetใซTupleใๅ
ฅใใๆใฎใ็ญๅคๆงๅคๅฎๆนๆณใฎๆๅฎใซไฝฟใใพใใ
/// HashSetใฎใณใณในใใฉใฏใฟใซๆธกใใฆไฝฟใใพใใ
/// EqualsใจGetHashCodeใๆไพใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// UnionFindTree
/// </summary>
public class UnionFindTree {
int[] Node;
public UnionFindTree(int N) {
Node = new int[N];
for (int i = 0; i < N; i++) {
Node[i] = -1;
}
}
public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); }
public bool Merge(int x, int y) {
int xr = GetRoot(x);
int yr = GetRoot(y);
if (xr == yr)
return false;
// xใใๅคงใใชใฐใซใผใใ็คบใใใใซSwapใใ๏ผๅคใๅฐใใๆนใๅคงใใชใฐใซใผใ๏ผ
if (Node[xr] > Node[yr])
Swap(ref xr, ref yr);
// ใฐใซใผใใฎๆฐใๅ็ฎใใ
Node[xr] += Node[yr];
// ๆ นใๅผตใๆฟใใ
Node[yr] = xr;
return true;
}
public int Size(int x) { return -Node[GetRoot(x)]; }
public int GetRoot(int n) {
if (Node[n] < 0) {
return n;
} else {
// ๆ นใๅผตใใชใใใ
Node[n] = GetRoot(Node[n]);
return Node[n];
}
}
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T> {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
return _comparison(x, y);
// if (_comparison != null) return _comparison(x, y);
// return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
#endregion
}
|
[["-", 0, 195, 8, 196, 0, 210, 39, 224, 39, 199], ["-", 8, 196, 0, 210, 39, 224, 225, 226, 0, 70], ["-", 8, 196, 0, 210, 39, 224, 225, 226, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 39, 199], ["+", 8, 201, 0, 195, 8, 196, 0, 210, 31, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 210, 12, 22], ["+", 0, 195, 8, 196, 0, 210, 12, 213, 63, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["+", 12, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["+", 12, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["+", 12, 213, 3, 4, 0, 28, 0, 74, 51, 22], ["+", 8, 196, 0, 210, 12, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 205, 204, 205, 22], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["-", 64, 196, 0, 1, 0, 11, 12, 204, 205, 22], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 70], ["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 1, 0, 11, 12, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 3,364
| 24
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ABC112.Cin;
using static ABC112.Util;
using static System.Console;
using System.Collections;
#if DEBUG
using System.Diagnostics;
#endif
/// <summary>
/// https://atcoder.jp/contests/abc112/tasks
/// </summary>
namespace ABC112 {
class Program {
static void Main(string[] args) {
START:
// ProgrammingEducation();
// TimeLimitExceeded();
Pyramid();
#if DEBUG
goto START;
#endif
}
private static void Pyramid() {
long N = ReadLong();
long[][] table = ReadLongTable(N);
string ans = null;
foreach (int cx in Range(101)) {
foreach (int cy in Range(101)) {
long? H = null;
bool first = true;
CHECK:
foreach (long[] info in table) {
long sum = Math.Abs(info[0] - cx) + Math.Abs(info[1] - cy);
// Hใnullใใคinfo[2]ใ0ใใใชใใจใใฏใHใๆจๅฎใใ
if (H == null && info[2] != 0)
H = sum + info[2];
if (H != null && info[2] == 0 && !(H <= sum))
goto CONTINUE;
if (H != null && H != sum + info[2])
goto CONTINUE;
}
if (first) {
first = false;
goto CHECK;
}
ans = string.Format("{0} {1} {2}", cx, cy, H);
goto BREAK;
CONTINUE:;
}
}
BREAK:
WriteLine(ans);
}
static void TimeLimitExceeded() {
int N = ReadInt();
int T = ReadInt();
int[][] C = ReadIntTable(N);
long ans = long.MaxValue;
foreach (var c in C) {
if (c[1] > T)
continue;
ChMin(ref ans, c[0]);
}
if (ans == long.MaxValue) {
WriteLine("TLE");
} else {
WriteLine(ans);
}
}
private static void ProgrammingEducation() {
int N = ReadInt();
if (N == 1) {
WriteLine("Hello World");
} else {
int A = ReadInt();
int B = ReadInt();
int ans = A + B;
WriteLine(ans);
}
}
}
#region ToolBox
public static class Cin {
static string[] Tokens { get; set; }
static int Ptr { get; set; }
public static string Next() {
if (Tokens == null || Tokens.Length <= Ptr) {
Tokens = Console.ReadLine().Split(' ');
Ptr = 0;
}
return Tokens[Ptr++];
}
public static int ReadInt() { return int.Parse(Next()); }
public static long ReadLong() { return long.Parse(Next()); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static int[][] ReadIntTable(int n) {
Tokens = null;
int[][] ret = new int [n][];
for (int i = 0; i < n; i++) {
ret[i] = ReadIntArray();
}
return ret;
}
public static long[][] ReadLongTable(long n) {
Tokens = null;
long[][] ret = new long [n][];
for (long i = 0; i < n; i++) {
ret[i] = ReadLongArray();
}
return ret;
}
public static string ReadString() {
Tokens = null;
return Console.ReadLine();
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใintใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().ToArray(),
c => int.Parse(c.ToString()));
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใboolใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
Tokens = null;
return Console.ReadLine().Select(c => c == '1').ToArray();
}
}
/// <summary>
/// ใฆใผใใฃใชใใฃใผ
/// </summary>
public static class Util {
// 10^17
public static readonly long INF = (long)1e17;
public static IEnumerable<int> Range(int end) {
for (int i = 0; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end) {
for (int i = from; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end, int step) {
for (int i = from; i < end; i += step) {
yield return i;
}
}
/// <summary>
/// ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// ้้ ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] ReverseSort<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyใซใใใใใชใใค
/// ex) 5.Times(i => Console.WriteLine(i));
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
/// <summary>
/// ๅผๆฐaใจๅผๆฐbใฎๅคใๅ
ฅใๆฟใใพใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
/// <summary>
/// Console.WriteLineใฎ่ชๅใใฉใใทใฅใใใชใใใใซใใ
/// </summary>
public static void DontAutoFlush() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
/// <summary>
/// ๅ
้ ญใจๆซๅฐพใซ่ฆ็ด ใๅขใใใๆฐใใ้
ๅใ่ฟใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] AddHeadAndTail<T>(T[] array) {
int len = array.Length;
T[] res = new T[len + 2];
Array.Copy(array, 0, res, 1, len);
return res;
}
/// <summary>
/// ๆ้ ใฝใผใๆธใฟใฎ้
ๅใ2ๅๆข็ดขใใพใใ
/// ่ฆ็ด ใ่ฆใคใใใชใใฃใๅ ดๅใฏnใใๅคงใใๆฐๅคใฎไธญใงๆๅฐใฎๆฐๅคใฎใคใณใใใฏในใ่ฟใใ
/// </summary>
/// <param name="array"></param>
/// <param name="n"></param>
/// <returns></returns>
public static int BinarySearch(long[] array, long n) {
int left = 0;
int right = array.Length - 1;
while (left <= right) {
int mid = (right - left) / 2 + left;
if (array[mid] == n) {
return mid;
} else if (n < array[mid]) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return left;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static int[] GetDivisor(int n) {
double sqrt = Math.Sqrt(n);
List<int> divisor = new List<int>();
for (int i = 1; i <= sqrt; i++) {
if (n % i == 0) {
divisor.Add(i);
int tmp = n / i;
if (tmp != i) {
divisor.Add(tmp);
}
}
}
return Sort(divisor.ToArray());
}
public static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
public static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
public static void Deconstruct<T>(this T[] items, out T t0) {
t0 = items.Length > 0 ? items[0] : default(T);
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1) {
if (items.Length < 2)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2) {
if (items.Length < 3)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2, out T t3) {
if (items.Length < 4)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
t3 = items[3];
}
public static void ArrayInitialize<T>(T[,] array, T value) {
int len0 = array.GetLength(0);
int len1 = array.GetLength(1);
for (int i = 0; i < len0; i++) {
for (int j = 0; j < len1; j++) {
array[i, j] = value;
}
}
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public readonly static int MOD = 1000000007;
public static void ModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long minValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (n < minValue) {
min = x;
}
}
return min;
}
public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long maxValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (maxValue < n) {
min = x;
}
}
return min;
}
#if DEBUG
static void SampleGenerator() {
int A = 1000;
int B = 1000;
int Q = 1000;
Random r = new Random();
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("{0} {1} {2}", A, B, Q));
A.Times(a => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
B.Times(b => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Q.Times(q => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Debug.WriteLine(sb.ToString());
}
#endif
}
/// <summary>
/// HashSetใซTupleใๅ
ฅใใๆใฎใ็ญๅคๆงๅคๅฎๆนๆณใฎๆๅฎใซไฝฟใใพใใ
/// HashSetใฎใณใณในใใฉใฏใฟใซๆธกใใฆไฝฟใใพใใ
/// EqualsใจGetHashCodeใๆไพใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// UnionFindTree
/// </summary>
public class UnionFindTree {
int[] Node;
public UnionFindTree(int N) {
Node = new int[N];
for (int i = 0; i < N; i++) {
Node[i] = -1;
}
}
public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); }
public bool Merge(int x, int y) {
int xr = GetRoot(x);
int yr = GetRoot(y);
if (xr == yr)
return false;
// xใใๅคงใใชใฐใซใผใใ็คบใใใใซSwapใใ๏ผๅคใๅฐใใๆนใๅคงใใชใฐใซใผใ๏ผ
if (Node[xr] > Node[yr])
Swap(ref xr, ref yr);
// ใฐใซใผใใฎๆฐใๅ็ฎใใ
Node[xr] += Node[yr];
// ๆ นใๅผตใๆฟใใ
Node[yr] = xr;
return true;
}
public int Size(int x) { return -Node[GetRoot(x)]; }
public int GetRoot(int n) {
if (Node[n] < 0) {
return n;
} else {
// ๆ นใๅผตใใชใใใ
Node[n] = GetRoot(Node[n]);
return Node[n];
}
}
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T> {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
return _comparison(x, y);
// if (_comparison != null) return _comparison(x, y);
// return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
#endregion
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static ABC112.Cin;
using static ABC112.Util;
using static System.Console;
using System.Collections;
#if DEBUG
using System.Diagnostics;
#endif
/// <summary>
/// https://atcoder.jp/contests/abc112/tasks
/// </summary>
namespace ABC112 {
class Program {
static void Main(string[] args) {
START:
// ProgrammingEducation();
// TimeLimitExceeded();
Pyramid();
#if DEBUG
goto START;
#endif
}
private static void Pyramid() {
long N = ReadLong();
long[][] table = ReadLongTable(N);
string ans = null;
foreach (int cx in Range(101)) {
foreach (int cy in Range(101)) {
long? H = null;
bool first = true;
CHECK:
foreach (long[] info in table) {
long sum = Math.Abs(info[0] - cx) + Math.Abs(info[1] - cy);
// Hใnullใงinfo[2]ใ0ใใใชใๅ ดๅHใๆจๅฎๅบๆฅใ
if (H == null && info[2] != 0)
H = sum + info[2];
if (H != null) {
if (info[2] == 0) {
if (!(H <= sum))
goto CONTINUE;
} else if (H != sum + info[2]) {
goto CONTINUE;
}
}
}
// ๅ
้ ญใฎๆนใ0ใ ใฃใๅ ดๅๆชใใงใใฏๅใใใใฎใงๅใใงใใฏใใ
if (first) {
first = false;
goto CHECK;
}
ans = string.Format("{0} {1} {2}", cx, cy, H);
goto BREAK;
CONTINUE:;
}
}
BREAK:
WriteLine(ans);
}
static void TimeLimitExceeded() {
int N = ReadInt();
int T = ReadInt();
int[][] C = ReadIntTable(N);
long ans = long.MaxValue;
foreach (var c in C) {
if (c[1] > T)
continue;
ChMin(ref ans, c[0]);
}
if (ans == long.MaxValue) {
WriteLine("TLE");
} else {
WriteLine(ans);
}
}
private static void ProgrammingEducation() {
int N = ReadInt();
if (N == 1) {
WriteLine("Hello World");
} else {
int A = ReadInt();
int B = ReadInt();
int ans = A + B;
WriteLine(ans);
}
}
}
#region ToolBox
public static class Cin {
static string[] Tokens { get; set; }
static int Ptr { get; set; }
public static string Next() {
if (Tokens == null || Tokens.Length <= Ptr) {
Tokens = Console.ReadLine().Split(' ');
Ptr = 0;
}
return Tokens[Ptr++];
}
public static int ReadInt() { return int.Parse(Next()); }
public static long ReadLong() { return long.Parse(Next()); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static int[][] ReadIntTable(int n) {
Tokens = null;
int[][] ret = new int [n][];
for (int i = 0; i < n; i++) {
ret[i] = ReadIntArray();
}
return ret;
}
public static long[][] ReadLongTable(long n) {
Tokens = null;
long[][] ret = new long [n][];
for (long i = 0; i < n; i++) {
ret[i] = ReadLongArray();
}
return ret;
}
public static string ReadString() {
Tokens = null;
return Console.ReadLine();
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใintใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().ToArray(),
c => int.Parse(c.ToString()));
}
/// <summary>
/// "00101001010"ใจใใๆงใชๅ
ฅๅใboolใฎ้
ๅใซใใฆ่ฟใ
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
Tokens = null;
return Console.ReadLine().Select(c => c == '1').ToArray();
}
}
/// <summary>
/// ใฆใผใใฃใชใใฃใผ
/// </summary>
public static class Util {
// 10^17
public static readonly long INF = (long)1e17;
public static IEnumerable<int> Range(int end) {
for (int i = 0; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end) {
for (int i = from; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end, int step) {
for (int i = from; i < end; i += step) {
yield return i;
}
}
/// <summary>
/// ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// ้้ ใฝใผใใใใฆ็ตๆใ่ฟใใพใใ
/// ็ ดๅฃ็้ขๆฐใงใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] ReverseSort<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyใซใใใใใชใใค
/// ex) 5.Times(i => Console.WriteLine(i));
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
/// <summary>
/// ๅผๆฐaใจๅผๆฐbใฎๅคใๅ
ฅใๆฟใใพใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
/// <summary>
/// Console.WriteLineใฎ่ชๅใใฉใใทใฅใใใชใใใใซใใ
/// </summary>
public static void DontAutoFlush() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
/// <summary>
/// ๅ
้ ญใจๆซๅฐพใซ่ฆ็ด ใๅขใใใๆฐใใ้
ๅใ่ฟใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] AddHeadAndTail<T>(T[] array) {
int len = array.Length;
T[] res = new T[len + 2];
Array.Copy(array, 0, res, 1, len);
return res;
}
/// <summary>
/// ๆ้ ใฝใผใๆธใฟใฎ้
ๅใ2ๅๆข็ดขใใพใใ
/// ่ฆ็ด ใ่ฆใคใใใชใใฃใๅ ดๅใฏnใใๅคงใใๆฐๅคใฎไธญใงๆๅฐใฎๆฐๅคใฎใคใณใใใฏในใ่ฟใใ
/// </summary>
/// <param name="array"></param>
/// <param name="n"></param>
/// <returns></returns>
public static int BinarySearch(long[] array, long n) {
int left = 0;
int right = array.Length - 1;
while (left <= right) {
int mid = (right - left) / 2 + left;
if (array[mid] == n) {
return mid;
} else if (n < array[mid]) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return left;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static int[] GetDivisor(int n) {
double sqrt = Math.Sqrt(n);
List<int> divisor = new List<int>();
for (int i = 1; i <= sqrt; i++) {
if (n % i == 0) {
divisor.Add(i);
int tmp = n / i;
if (tmp != i) {
divisor.Add(tmp);
}
}
}
return Sort(divisor.ToArray());
}
public static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
public static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
public static void Deconstruct<T>(this T[] items, out T t0) {
t0 = items.Length > 0 ? items[0] : default(T);
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1) {
if (items.Length < 2)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2) {
if (items.Length < 3)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2, out T t3) {
if (items.Length < 4)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
t3 = items[3];
}
public static void ArrayInitialize<T>(T[,] array, T value) {
int len0 = array.GetLength(0);
int len1 = array.GetLength(1);
for (int i = 0; i < len0; i++) {
for (int j = 0; j < len1; j++) {
array[i, j] = value;
}
}
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public readonly static int MOD = 1000000007;
public static void ModAdd(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long minValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (n < minValue) {
min = x;
}
}
return min;
}
public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long maxValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (maxValue < n) {
min = x;
}
}
return min;
}
#if DEBUG
static void SampleGenerator() {
int A = 1000;
int B = 1000;
int Q = 1000;
Random r = new Random();
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Format("{0} {1} {2}", A, B, Q));
A.Times(a => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
B.Times(b => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Q.Times(q => sb.AppendLine(((long)r.Next() * r.Next()).ToString()));
Debug.WriteLine(sb.ToString());
}
#endif
}
/// <summary>
/// HashSetใซTupleใๅ
ฅใใๆใฎใ็ญๅคๆงๅคๅฎๆนๆณใฎๆๅฎใซไฝฟใใพใใ
/// HashSetใฎใณใณในใใฉใฏใฟใซๆธกใใฆไฝฟใใพใใ
/// EqualsใจGetHashCodeใๆไพใใพใใ
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// UnionFindTree
/// </summary>
public class UnionFindTree {
int[] Node;
public UnionFindTree(int N) {
Node = new int[N];
for (int i = 0; i < N; i++) {
Node[i] = -1;
}
}
public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); }
public bool Merge(int x, int y) {
int xr = GetRoot(x);
int yr = GetRoot(y);
if (xr == yr)
return false;
// xใใๅคงใใชใฐใซใผใใ็คบใใใใซSwapใใ๏ผๅคใๅฐใใๆนใๅคงใใชใฐใซใผใ๏ผ
if (Node[xr] > Node[yr])
Swap(ref xr, ref yr);
// ใฐใซใผใใฎๆฐใๅ็ฎใใ
Node[xr] += Node[yr];
// ๆ นใๅผตใๆฟใใ
Node[yr] = xr;
return true;
}
public int Size(int x) { return -Node[GetRoot(x)]; }
public int GetRoot(int n) {
if (Node[n] < 0) {
return n;
} else {
// ๆ นใๅผตใใชใใใ
Node[n] = GetRoot(Node[n]);
return Node[n];
}
}
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T> {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
return _comparison(x, y);
// if (_comparison != null) return _comparison(x, y);
// return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
#endregion
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 0, 97, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["-", 0, 210, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 215], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 79], ["+", 64, 196, 0, 57, 75, 57, 64, 196, 0, 45], ["+", 64, 196, 0, 57, 75, 57, 64, 196, 0, 46], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 3,224
| 19
|
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute =
System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute =
System.Runtime.InteropServices.FieldOffsetAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
int n = int.Parse(Console.ReadLine());
var xyh =
Enumerable.Repeat(0, n)
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
int hmax = int.MaxValue;
int h = -1;
foreach (var item in xyh) {
var dist = Abs(item[0] - cx) + Abs(item[1] - cy);
if (item[2] == 0)
hmax = Min(hmax, dist);
else {
if (h == -1)
h = dist + item[2];
else if (h != dist + item[2])
goto end;
}
}
Console.WriteLine($"{cx} {cy} {h}");
return;
end:;
}
}
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute =
System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute =
System.Runtime.InteropServices.FieldOffsetAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
int n = int.Parse(Console.ReadLine());
var xyh =
Enumerable.Repeat(0, n)
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
int hmax = int.MaxValue;
int h = -1;
foreach (var item in xyh) {
var dist = Abs(item[0] - cx) + Abs(item[1] - cy);
if (item[2] == 0)
hmax = Min(hmax, dist);
else {
if (h == -1)
h = dist + item[2];
else if (h != dist + item[2])
goto end;
}
}
if (h > hmax || hmax < 1)
goto end;
if (h == -1)
h = hmax;
Console.WriteLine($"{cx} {cy} {h}");
return;
end:;
}
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 7, 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, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 126, 0, 127], ["+", 0, 7, 8, 196, 0, 57, 64, 126, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 126, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 203], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 340
| 24
|
using System;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
struct Point {
public int X { get; }
public int Y { get; }
public long Height { get; }
public Point(int x, int y, long height) {
X = x;
Y = y;
Height = height;
}
}
class Program {
static bool Satisfies(Point center, Point[] points) {
foreach (var p in points) {
long expected =
Max(center.Height - Abs(center.X - p.X) - Abs(center.Y - p.Y), 0);
if (p.Height != expected) {
return false;
}
}
return true;
}
static Point Solve(Point[] points) {
for (int x = 0; x <= 100; x++) {
for (int y = 0; y <= 100; y++) {
int distance = Abs(points[0].X - x) + Abs(points[0].Y - y);
long height = points[0].Height + distance;
Point center = new Point(x, y, height);
if (Satisfies(center, points)) {
return center;
}
}
}
throw new InvalidOperationException();
}
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
Point[] points =
(from _ in Enumerable.Repeat(0, n) let cols =
Console.ReadLine().Split() select new Point(
int.Parse(cols[0]), int.Parse(cols[1]), long.Parse(cols[2])))
.ToArray();
Point center = Solve(points);
Console.WriteLine($"{center.X} {center.Y} {center.Height}");
}
}
}
|
using System;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
struct Point {
public int X { get; }
public int Y { get; }
public long Height { get; }
public Point(int x, int y, long height) {
X = x;
Y = y;
Height = height;
}
}
class Program {
static bool Satisfies(Point center, Point[] points) {
foreach (var p in points) {
long expected =
Max(center.Height - Abs(center.X - p.X) - Abs(center.Y - p.Y), 0);
if (p.Height != expected) {
return false;
}
}
return true;
}
static Point Solve(Point[] points) {
for (int x = 0; x <= 100; x++) {
for (int y = 0; y <= 100; y++) {
int distance = Abs(points[0].X - x) + Abs(points[0].Y - y);
long height = points[0].Height + distance;
Point center = new Point(x, y, height);
if (Satisfies(center, points)) {
return center;
}
}
}
throw new InvalidOperationException();
}
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
Point[] points = (from _ in Enumerable.Repeat(0, n) let cols =
Console.ReadLine().Split() let p =
new Point(int.Parse(cols[0]), int.Parse(cols[1]),
long.Parse(cols[2]))
orderby p.Height descending select p)
.ToArray();
Point center = Solve(points);
Console.WriteLine($"{center.X} {center.Y} {center.Height}");
}
}
}
|
[["-", 0, 55, 0, 220, 0, 212, 0, 42, 0, 245], ["+", 0, 42, 0, 220, 0, 212, 0, 42, 0, 243], ["+", 0, 42, 0, 220, 0, 212, 0, 11, 31, 22], ["+", 0, 212, 0, 11, 0, 42, 0, 202, 0, 32], ["+", 0, 212, 0, 11, 0, 42, 0, 42, 0, 325], ["+", 0, 212, 0, 11, 0, 42, 0, 232, 234, 22], ["+", 0, 212, 0, 11, 0, 42, 0, 232, 0, 131], ["+", 0, 212, 0, 11, 0, 42, 0, 232, 141, 22], ["+", 0, 11, 0, 42, 0, 42, 0, 22, 0, 326], ["+", 0, 212, 0, 11, 0, 42, 0, 42, 0, 245], ["+", 0, 220, 0, 212, 0, 11, 0, 42, 0, 42], ["+", 0, 212, 0, 11, 0, 42, 0, 42, 0, 22], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 42, 0, 220, 0, 212, 0, 11, 0, 42], ["+", 0, 220, 0, 212, 0, 11, 0, 42, 0, 202], ["+", 0, 212, 0, 11, 0, 42, 0, 202, 0, 42], ["+", 0, 11, 0, 42, 0, 202, 0, 42, 0, 230], ["+", 0, 42, 0, 202, 0, 42, 0, 230, 39, 22], ["+", 0, 202, 0, 42, 0, 230, 39, 22, 3, 4], ["+", 0, 42, 0, 230, 39, 22, 3, 4, 0, 232], ["+", 0, 230, 39, 22, 3, 4, 0, 232, 234, 22], ["+", 39, 22, 3, 4, 0, 232, 234, 22, 141, 22], ["+", 3, 4, 0, 232, 234, 22, 141, 22, 0, 42], ["+", 0, 232, 234, 22, 141, 22, 0, 42, 0, 22], ["+", 234, 22, 141, 22, 0, 42, 0, 22, 0, 55], ["+", 141, 22, 0, 42, 0, 22, 0, 55, 0, 22], ["+", 0, 23, 0, 213, 3, 4, 0, 25, 0, 25]]
| 8
| 388
| 14
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
class Program {
static int N;
public static void Main(string[] args) {
N = Input.NextInt();
var x = new int[N];
var y = new int[N];
var h = new int[N];
int samplex = 0, sampley = 0, sampleh = 0;
foreach (var i in Enumerable.Range(0, N)) {
var xyh = Input.LineInt();
x[i] = xyh[0];
y[i] = xyh[1];
h[i] = xyh[2];
if (h[i] != 0) {
samplex = x[i];
sampley = y[i];
sampleh = h[i];
}
}
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var hh = sampleh + Math.Abs(cx - samplex) + Math.Abs(cy - sampley);
for (int i = 0; i < N; i++) {
var HC =
Math.Max(h[i] + Math.Abs(cx - x[i]) + Math.Abs(cy - y[i]), 0);
if (HC != hh)
goto L_nextcand;
}
Console.WriteLine($"{cx} {cy} {hh}");
return;
L_nextcand:;
}
}
throw new Exception();
}
}
public static class Input {
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();
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
class Program {
static int N;
public static void Main(string[] args) {
N = Input.NextInt();
var x = new int[N];
var y = new int[N];
var h = new int[N];
int samplex = 0, sampley = 0, sampleh = 0;
foreach (var i in Enumerable.Range(0, N)) {
var xyh = Input.LineInt();
x[i] = xyh[0];
y[i] = xyh[1];
h[i] = xyh[2];
if (h[i] != 0) {
samplex = x[i];
sampley = y[i];
sampleh = h[i];
}
}
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var hh = sampleh + Math.Abs(cx - samplex) + Math.Abs(cy - sampley);
for (int i = 0; i < N; i++) {
var HC = Math.Max(hh - Math.Abs(cx - x[i]) - Math.Abs(cy - y[i]), 0);
if (HC != h[i])
goto L_nextcand;
}
Console.WriteLine($"{cx} {cy} {hh}");
return;
L_nextcand:;
}
}
throw new Exception();
}
}
public static class Input {
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();
}
}
|
[["-", 0, 28, 0, 16, 31, 16, 31, 204, 205, 22], ["-", 0, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 16, 31, 16, 31, 204, 206, 207, 0, 73], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 616
| 14
|
using System;
using System.Linq;
using System.Collections.Generic;
class Cmondai {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
var list = new List<long[]>();
for (int i = 0; i < N; ++i) {
var xyh = Console.ReadLine()
.Split(' ')
.Select(num => Int64.Parse(num))
.ToArray();
var x = xyh[0];
var y = xyh[1];
var h = xyh[2];
list.Add(new long[3] { x, y, h });
}
var kizyun = list.Where(x => x[2] != 0).First();
for (int i = 0; i <= 100; ++i) {
for (int j = 0; j <= 100; ++j) {
var height =
kizyun[2] + Math.Abs(kizyun[0] - i) + Math.Abs(kizyun[1] - j);
var isCorrect = true;
for (int k = 0; k < N; ++k) {
if (list[k][2] + Math.Abs(list[k][0] - i) +
Math.Abs(list[k][1] - j) !=
height) {
isCorrect = false;
break;
}
}
if (isCorrect) {
Console.WriteLine($"{i} {j} {height}");
return;
}
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Cmondai {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
var list = new List<long[]>();
for (int i = 0; i < N; ++i) {
var xyh = Console.ReadLine()
.Split(' ')
.Select(num => Int64.Parse(num))
.ToArray();
var x = xyh[0];
var y = xyh[1];
var h = xyh[2];
list.Add(new long[3] { x, y, h });
}
var kizyun = list.Where(x => x[2] != 0).First();
for (int i = 0; i <= 100; ++i) {
for (int j = 0; j <= 100; ++j) {
var height =
kizyun[2] + Math.Abs(kizyun[0] - i) + Math.Abs(kizyun[1] - j);
var isCorrect = true;
for (int k = 0; k < N; ++k) {
if (Math.Max(0, height - Math.Abs(list[k][0] - i) -
Math.Abs(list[k][1] - j)) != list[k][2]) {
isCorrect = false;
break;
}
}
if (isCorrect) {
Console.WriteLine($"{i} {j} {height}");
return;
}
}
}
}
}
|
[["-", 31, 16, 31, 16, 31, 204, 205, 204, 205, 22], ["-", 31, 16, 31, 204, 205, 204, 206, 207, 0, 70], ["-", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["-", 31, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["-", 31, 16, 31, 16, 31, 204, 206, 207, 0, 70], ["-", 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, 72], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 31, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 204, 205, 204, 205, 22], ["+", 15, 16, 12, 204, 205, 204, 206, 207, 0, 70], ["+", 12, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 15, 16, 12, 204, 205, 204, 206, 207, 0, 73], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 70], ["+", 15, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 12, 204, 206, 207, 0, 73]]
| 8
| 326
| 27
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static AtCoderTemplate.MyExtensions;
using static AtCoderTemplate.MyInputOutputs;
using static AtCoderTemplate.MyNumericFunctions;
namespace AtCoderTemplate {
class Program {
static void Main(string[] args) {
var N = ReadInt();
var seq = Enumerable.Range(0, N)
.Select(i => Console.ReadLine()
.Split(' ')
.Select(c => long.Parse(c))
.ToList())
.ToList();
var xyh = Enumerable.Range(0, seq.First().Count())
.Select(i => seq.Select(items => items[i]).ToList())
.ToList();
var x = xyh[0];
var y = xyh[1];
var h = xyh[2];
foreach (var cy in Enumerable.Range(0, 101)) {
foreach (var cx in Enumerable.Range(0, 101)) {
var maybeIndex = Enumerable.Range(0, N).Where(i => h[i] != 0).First();
var maybeH =
h[maybeIndex] + Abs(x[maybeIndex] - cx) + Abs(y[maybeIndex] - cy);
var isCorrect = Enumerable.Range(1, N - 1).All(
i => h[i] == Max(maybeH - Abs(x[i] - cx) - Abs(y[i] - cy), 0));
if (isCorrect) {
Console.WriteLine($"{cx} {cy} {maybeH}");
return;
}
}
}
}
}
static class MyInputOutputs {
/* Input & Output*/
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
public static List<List<int>> ReadColumns(int n) {
/*
ๅ
ฅๅไพ
A1 B1
A2 B2
...
An Bn
ๅบๅไพ
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var seq = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
return Enumerable.Range(0, seq.First().Count())
.Select(i => seq.Select(items => items[i]).ToList())
.ToList();
}
public static void PrintEnum<T>(IEnumerable<T> list) {
Console.Write(list.First());
foreach (var item in list.Skip(1)) {
Console.Write($" {item}");
}
Console.Write("\n");
}
public static void PrintLnEnum<T>(IEnumerable<T> list) {
foreach (var item in list) {
Console.WriteLine(item);
}
}
}
static class MyNumericFunctions {
public static int Fact(int n) {
return Enumerable.Range(1, n).Aggregate(1, ((i, k) => i * k));
}
public static int PermNum(int n, int m) {
if (m > n) {
return 0;
}
return Enumerable.Range(n - m, m + 1).Aggregate(1, ((i, k) => i * k));
}
public static int CombNum(int n, int m) { return PermNum(n, m) / Fact(m); }
// ๆๅคงๅ
ฌ็ดๆฐ (m โง n)
public static int GCD(int m, int n) {
if (n == 0) {
return m;
} else {
return GCD(n, m % n);
}
}
// ๆๅฐๅ
ฌๅๆฐ (m โง n)
public static int LCM(int m, int n) { return GCD(m, n) / (m * n); }
}
static class MyExtensions {
/// <summary>
/// ไธใคๅใฎๅคใจใฎๅทฎใๅพใ
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> Diff(this IEnumerable<int> source) {
var list = source.ToList();
return Enumerable.Range(1, list.Count - 1)
.Select(i => list[i] - list[i - 1]);
}
/// <summary>
/// ็ดฏ็ฉๅใๅพใ
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> CumSum(this IEnumerable<int> source) {
var list = source.ToList();
var result = new List<int> { list[0] };
foreach (var i in Enumerable.Range(1, source.Count() - 1)) {
result.Add(result[i - 1] + list[i]);
}
return result;
}
/// <summary>
/// ๆ้ ใซใฝใผใใใใคใณใใใฏในใๅพใ
/// </summary>
public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) {
return source.Select((item, i) => new { Item = item, Index = i })
.OrderBy(x => x.Item)
.Select(x => x.Index);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static AtCoderTemplate.MyExtensions;
using static AtCoderTemplate.MyInputOutputs;
using static AtCoderTemplate.MyNumericFunctions;
namespace AtCoderTemplate {
class Program {
static void Main(string[] args) {
var N = ReadInt();
var seq = Enumerable.Range(0, N)
.Select(i => Console.ReadLine()
.Split(' ')
.Select(c => long.Parse(c))
.ToList())
.ToList();
var xyh = Enumerable.Range(0, seq.First().Count())
.Select(i => seq.Select(items => items[i]).ToList())
.ToList();
var x = xyh[0];
var y = xyh[1];
var h = xyh[2];
var correct = new List<List<long>>();
foreach (var cy in Enumerable.Range(0, 101)) {
foreach (var cx in Enumerable.Range(0, 101)) {
var maybeIndex = Enumerable.Range(0, N).Where(i => h[i] != 0).First();
var maybeH =
h[maybeIndex] + Abs(x[maybeIndex] - cx) + Abs(y[maybeIndex] - cy);
var isCorrect = Enumerable.Range(0, N).All(
i => h[i] == Max(maybeH - Abs(x[i] - cx) - Abs(y[i] - cy), 0));
if (isCorrect) {
Console.WriteLine($"{cx} {cy} {maybeH}");
return;
}
}
}
}
}
static class MyInputOutputs {
/* Input & Output*/
public static int ReadInt() { return int.Parse(Console.ReadLine()); }
public static List<int> ReadInts() {
return Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
}
public static List<List<int>> ReadColumns(int n) {
/*
ๅ
ฅๅไพ
A1 B1
A2 B2
...
An Bn
ๅบๅไพ
[[A1,A2,...,An], [B1,B2,...,Bn]]
*/
var seq = Enumerable.Range(0, n).Select(i => ReadInts()).ToList();
return Enumerable.Range(0, seq.First().Count())
.Select(i => seq.Select(items => items[i]).ToList())
.ToList();
}
public static void PrintEnum<T>(IEnumerable<T> list) {
Console.Write(list.First());
foreach (var item in list.Skip(1)) {
Console.Write($" {item}");
}
Console.Write("\n");
}
public static void PrintLnEnum<T>(IEnumerable<T> list) {
foreach (var item in list) {
Console.WriteLine(item);
}
}
}
static class MyNumericFunctions {
public static int Fact(int n) {
return Enumerable.Range(1, n).Aggregate(1, ((i, k) => i * k));
}
public static int PermNum(int n, int m) {
if (m > n) {
return 0;
}
return Enumerable.Range(n - m, m + 1).Aggregate(1, ((i, k) => i * k));
}
public static int CombNum(int n, int m) { return PermNum(n, m) / Fact(m); }
// ๆๅคงๅ
ฌ็ดๆฐ (m โง n)
public static int GCD(int m, int n) {
if (n == 0) {
return m;
} else {
return GCD(n, m % n);
}
}
// ๆๅฐๅ
ฌๅๆฐ (m โง n)
public static int LCM(int m, int n) { return GCD(m, n) / (m * n); }
}
static class MyExtensions {
/// <summary>
/// ไธใคๅใฎๅคใจใฎๅทฎใๅพใ
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> Diff(this IEnumerable<int> source) {
var list = source.ToList();
return Enumerable.Range(1, list.Count - 1)
.Select(i => list[i] - list[i - 1]);
}
/// <summary>
/// ็ดฏ็ฉๅใๅพใ
/// O(N * log(N))
/// </summary>
public static IEnumerable<int> CumSum(this IEnumerable<int> source) {
var list = source.ToList();
var result = new List<int> { list[0] };
foreach (var i in Enumerable.Range(1, source.Count() - 1)) {
result.Add(result[i - 1] + list[i]);
}
return result;
}
/// <summary>
/// ๆ้ ใซใฝใผใใใใคใณใใใฏในใๅพใ
/// </summary>
public static IEnumerable<int> SortIndex<T>(this IEnumerable<T> source) {
return source.Select((item, i) => new { Item = item, Index = i })
.OrderBy(x => x.Item)
.Select(x => x.Index);
}
}
}
|
[["+", 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, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 0, 230, 39, 236, 237, 238, 0, 236, 141, 22], ["+", 39, 236, 237, 238, 0, 236, 237, 238, 0, 18], ["+", 39, 236, 237, 238, 0, 236, 237, 238, 0, 199], ["+", 39, 236, 237, 238, 0, 236, 237, 238, 0, 47], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 1,002
| 18
|
using System;
using System.Collections.Generic;
// using System.Linq;
class Program {
static void Main(string[] args) {
// ๅ
ฅๅใใงใผใบ
// string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(Console.ReadLine());
List<point> coordinate = new List<point>();
for (int i = 0; i < N; i++) {
string[] input = Console.ReadLine().Split(' ');
point p = new point();
p.x = int.Parse(input[0]);
p.y = int.Parse(input[1]);
p.h = int.Parse(input[2]);
coordinate.Add(p);
}
// ๅบงๆจ1~100, 1~100ใซใคใใฆไธญๅฟ็นใจใชใใใใๅคๅฎใใ
bool isCenter = true;
point center = new point();
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
// ๅบงๆจ(i, j)ใฏไธญๅฟ็นใๆบใใใ๏ผ
// Console.Write(i + " " + j + " is Center? ");
int H = 0;
isCenter = true;
for (int k = 0; k < N; k++) {
point pyramid = coordinate[k];
if (k == 0) {
// Hใฑใใใค
H = pyramid.h + Math.Abs(i - pyramid.x) + Math.Abs(j - pyramid.y);
// Console.WriteLine("height is " + H);
} else {
int hh =
pyramid.h + Math.Abs(i - pyramid.x) + Math.Abs(j - pyramid.y);
if (H != hh) {
isCenter = false;
break;
}
}
}
if (isCenter) {
center.x = i;
center.y = j;
center.h = H;
break;
}
}
if (isCenter)
break;
}
Console.WriteLine(center.x + " " + center.y + " " + center.h);
}
class point {
public int x { set; get; }
public int y { set; get; }
public int h { set; get; }
}
}
|
using System;
using System.Collections.Generic;
// using System.Linq;
class Program {
static void Main(string[] args) {
// ๅ
ฅๅใใงใผใบ
// string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(Console.ReadLine());
List<point> coordinate = new List<point>();
for (int i = 0; i < N; i++) {
string[] input = Console.ReadLine().Split(' ');
point p = new point();
p.x = int.Parse(input[0]);
p.y = int.Parse(input[1]);
p.h = int.Parse(input[2]);
coordinate.Add(p);
}
// ๅบงๆจ1~100, 1~100ใซใคใใฆไธญๅฟ็นใจใชใใใใๅคๅฎใใ
bool isCenter = true;
point center = new point();
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
// ๅบงๆจ(i, j)ใฏไธญๅฟ็นใๆบใใใ๏ผ
// Console.Write(i + " " + j + " is Center? ");
int H = 0;
isCenter = true;
for (int k = 0; k < N; k++) {
point pyramid = coordinate[k];
if (pyramid.h > 0) {
H = pyramid.h + Math.Abs(i - pyramid.x) + Math.Abs(j - pyramid.y);
break;
}
}
foreach (var py in coordinate) {
int hh = Math.Max(H - Math.Abs(i - py.x) - Math.Abs(j - py.y), 0);
if (hh != py.h) {
isCenter = false;
break;
}
}
if (isCenter) {
center.x = i;
center.y = j;
center.h = H;
break;
}
}
if (isCenter)
break;
}
Console.WriteLine(center.x + " " + center.y + " " + center.h);
}
class point {
public int x { set; get; }
public int y { set; get; }
public int h { set; get; }
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 31, 214, 141, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 7, 8, 196, 0, 210, 0, 266], ["+", 8, 196, 0, 7, 8, 196, 0, 210, 0, 24], ["+", 0, 7, 8, 196, 0, 210, 39, 216, 0, 217], ["+", 8, 196, 0, 7, 8, 196, 0, 210, 31, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 210, 0, 267], ["+", 8, 196, 0, 7, 8, 196, 0, 210, 12, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 210, 0, 25], ["-", 0, 212, 0, 16, 31, 16, 31, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 16, 31, 16, 31, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 3, 4, 0, 28, 0, 16, 12, 214, 205, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 214, 205, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 28, 0, 16, 12, 213, 3, 4, 0, 25], ["+", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 79], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 79], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 0, 131], ["+", 8, 196, 0, 57, 15, 16, 12, 214, 141, 22], ["-", 0, 57, 75, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 400
| 41
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
// https://beta.atcoder.jp/contests/abc112/tasks/abc112_c
public class Program_ABC112_C // โClassๅๅคๆด๏ผ๏ผ
{
public static void Main(string[] args) {
var n = int.Parse(ReadLine());
var points = new int [n][];
for (int i = 0; i < n; i++) {
points[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
}
Array.Sort(
points,
(a, b) => b[2].CompareTo(
a[2])); //้ซใ้ ใซใฝใผใ
//ๅ
้ ญใ้ซใใผใญใ ใจh1ใๆญฃใใๅคใซใชใใชใใฎใงใฝใผใใใใ
var crest = new int[3] { -1, -1, -1 };
for (var x = 0; x < 101; x++) {
var xConst = points[0][2] + Abs(x - points[0][0]);
for (var y = 0; y < 101; y++) {
var h1 = xConst + Abs(y - points[0][1]);
var isCrest = true;
for (int i = 1; i < n; i++) {
var h2 = points[i][2] + Abs(x - points[i][0]) + Abs(y - points[i][1]);
if (0 < points[i][2]) {
//ๅบงๆจใซ้ซใใใใใจใใใใจใฏใใใฉใใใใฎไธ้จใชใฎใงใh1=h2ใๆใ็ซใค
if (h1 != h2) {
isCrest = false;
break;
}
} else {
//ๅบงๆจใฎ้ซใใ0ใฎๅ ดๅใใใฉใใใใฎๅบ่พบใใใใฏใใใฉใใใใฎ้ซใใจใฏ้ขไฟใชใๅบงๆจใฎ2ใคใ่ใใใใใ
//ใใฉใใใใฎๅบ่พบใฎๅ ดๅh1=h2ใจใชใใ็ก้ขไฟใชๅบงๆจใง้ ็นใ่จ็ฎใใใจใh2<h1ใจใชใใ
//้ ็นใๆฑใใใฎใซๅๅใช่ชฟๆปใ่กใใใใใจใฏๆธใใฆใใใใไฝ่จใช่ชฟๆปใ่กใใใฆใใชใใจใฏๆธใใฆใชใ
if (h1 < h2) {
isCrest = false;
break;
}
}
}
if (isCrest) {
crest = new[] { x, y, h1 };
Console.WriteLine($"{x} {y} {h1}");
return;
// break;
}
}
}
// Console.WriteLine($"{crest[0]} {crest[1]} {crest[2]}");
} // Main
} // Class
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
// https://beta.atcoder.jp/contests/abc112/tasks/abc112_c
public class Program_ABC112_C // โClassๅๅคๆด๏ผ๏ผ
{
public static void Main(string[] args) {
var n = int.Parse(ReadLine());
var points = new int [n][];
for (int i = 0; i < n; i++) {
points[i] = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
}
Array.Sort(
points,
(a, b) => b[2].CompareTo(
a[2])); //้ซใ้ ใซใฝใผใ
//ๅ
้ ญใ้ซใใผใญใ ใจh1ใๆญฃใใๅคใซใชใใชใใฎใงใฝใผใใใใ
var crest = new int[3] { -1, -1, -1 };
for (var x = 0; x < 101; x++) {
var xConst = points[0][2] + Abs(x - points[0][0]);
for (var y = 0; y < 101; y++) {
var h1 = xConst + Abs(y - points[0][1]);
var isCrest = true;
for (int i = 1; i < n; i++) {
var h2 = points[i][2] + Abs(x - points[i][0]) + Abs(y - points[i][1]);
if (0 < points[i][2]) {
//ๅบงๆจใซ้ซใใใใใจใใใใจใฏใใใฉใใใใฎไธ้จใชใฎใงใh1=h2ใๆใ็ซใค
if (h1 != h2) {
isCrest = false;
break;
}
} else {
//ๅบงๆจใฎ้ซใใ0ใฎๅ ดๅใใใฉใใใใฎๅบ่พบใใใใฏใใใฉใใใใฎ้ซใใจใฏ้ขไฟใชใๅบงๆจใฎ2ใคใ่ใใใใใ
//ใใฉใใใใฎๅบ่พบใฎๅ ดๅh1=h2ใจใชใใ็ก้ขไฟใชๅบงๆจใง้ ็นใ่จ็ฎใใใจใh2<h1ใจใชใใ
//้ ็นใๆฑใใใฎใซๅๅใช่ชฟๆปใ่กใใใใใจใฏๆธใใฆใใใใไฝ่จใช่ชฟๆปใ่กใใใฆใใชใใจใฏๆธใใฆใชใ
// if (h1 < h2)
if (h2 < h1) {
isCrest = false;
break;
}
}
}
if (isCrest) {
crest = new[] { x, y, h1 };
// Console.WriteLine($"{x} {y} {h1}");
// return;
break;
}
}
}
Console.WriteLine($"{crest[0]} {crest[1]} {crest[2]}");
} // Main
} // Class
|
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["+", 0, 28, 0, 283, 0, 284, 0, 204, 205, 22], ["+", 0, 283, 0, 284, 0, 204, 206, 207, 0, 70], ["+", 0, 284, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 283, 0, 284, 0, 204, 206, 207, 0, 73], ["-", 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, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 382
| 4
|
using System;
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] x = new int[N];
int[] y = new int[N];
int[] h = new int[N];
for (int i = 0; i < N; i++) {
string[] array = Console.ReadLine().Split(' ');
x[i] = int.Parse(array[0]);
y[i] = int.Parse(array[1]);
h[i] = int.Parse(array[2]);
}
int sel = 0;
for (int i = 0; i < N; i++) {
if (h[i] > 0) {
sel = i;
break;
}
}
int[,] H = new int[101, 101];
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
H[i, j] = h[sel] + Math.Abs(x[sel] - i) + Math.Abs(y[sel] - j);
}
}
for (int n = 0; n < N; n++) {
if (n == sel)
continue;
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
if (H[i, j] <= 0)
continue;
if (H[i, j] != (h[n] + Math.Abs(x[n] - i) + Math.Abs(y[n] - j)))
H[i, j] = -1;
}
}
}
for (int i = 0; i <= 100; i++) {
bool flag = false;
for (int j = 0; j <= 100; j++) {
if (H[i, j] > 0) {
Console.WriteLine(i + " " + j + " " + H[i, j]);
flag = true;
break;
}
}
if (flag)
break;
}
}
}
|
using System;
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] x = new int[N];
int[] y = new int[N];
int[] h = new int[N];
for (int i = 0; i < N; i++) {
string[] array = Console.ReadLine().Split(' ');
x[i] = int.Parse(array[0]);
y[i] = int.Parse(array[1]);
h[i] = int.Parse(array[2]);
}
int sel = 0;
for (int i = 0; i < N; i++) {
if (h[i] > 0) {
sel = i;
break;
}
}
int[,] H = new int[101, 101];
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
H[i, j] = h[sel] + Math.Abs(x[sel] - i) + Math.Abs(y[sel] - j);
}
}
for (int n = 0; n < N; n++) {
if (n == sel)
continue;
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
if (H[i, j] <= 0)
continue;
if (h[n] !=
Math.Max(H[i, j] - Math.Abs(x[n] - i) - Math.Abs(y[n] - j), 0))
H[i, j] = -1;
}
}
}
for (int i = 0; i <= 100; i++) {
bool flag = false;
for (int j = 0; j <= 100; j++) {
if (H[i, j] > 0) {
Console.WriteLine(i + " " + j + " " + H[i, j]);
flag = true;
break;
}
}
if (flag)
break;
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 21], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 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], ["-", 12, 23, 0, 16, 31, 16, 31, 204, 205, 22], ["+", 0, 28, 0, 16, 31, 16, 31, 204, 205, 22], ["-", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 31, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 16, 31, 16, 31, 204, 206, 207, 0, 21], ["-", 15, 16, 12, 23, 0, 16, 31, 16, 17, 72], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 465
| 21
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.C_Challenge {
class ABC_112 {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
var xs = new long[n];
var ys = new long[n];
var hs = new long[n];
int baseIndex = 0;
for (int i = 0; i < n; i++) {
long[] input = ReadLongs();
xs[i] = input[0];
ys[i] = input[1];
hs[i] = input[2];
if (hs[i] > 0) {
baseIndex = i;
}
}
for (long x = 0; x <= 100; x++) {
for (long y = 0; y <= 100; y++) {
bool ok = true;
long h = hs[baseIndex] + Math.Abs(xs[baseIndex] - x) +
Math.Abs(ys[baseIndex] - y);
for (int i = 0; i < n; i++) {
long hTemp = h - Math.Abs(xs[i] - x) - Math.Abs(ys[i] - y);
if (hTemp != hs[i]) {
ok = false;
break;
}
}
if (ok) {
Console.WriteLine(x + " " + y + " " + h);
return;
}
}
}
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.C_Challenge {
class ABC_112 {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
int n = ReadInt();
var xs = new long[n];
var ys = new long[n];
var hs = new long[n];
int baseIndex = 0;
for (int i = 0; i < n; i++) {
long[] input = ReadLongs();
xs[i] = input[0];
ys[i] = input[1];
hs[i] = input[2];
if (hs[i] > 0) {
baseIndex = i;
}
}
for (long x = 0; x <= 100; x++) {
for (long y = 0; y <= 100; y++) {
bool ok = true;
long h = hs[baseIndex] + Math.Abs(xs[baseIndex] - x) +
Math.Abs(ys[baseIndex] - y);
for (int i = 0; i < n; i++) {
long hTemp = h - Math.Abs(xs[i] - x) - Math.Abs(ys[i] - y);
if (hTemp < 0)
hTemp = 0;
if (hTemp != hs[i]) {
ok = false;
break;
}
}
if (ok) {
Console.WriteLine(x + " " + y + " " + h);
return;
}
}
}
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 478
| 10
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[,] A = new long[N, 3];
for (var i = 0; i < N; i++) {
string[] str = Console.ReadLine().Split();
A[i, 0] = long.Parse(str[0]);
A[i, 1] = long.Parse(str[1]);
A[i, 2] = long.Parse(str[2]);
}
long it = 0;
long jt = 0;
while (true) {
long amin = Math.Abs(it - A[0, 0]) + Math.Abs(jt - A[0, 1]) + A[0, 2];
long amax = Math.Abs(it - A[0, 0]) + Math.Abs(jt - A[0, 1]) + A[0, 2];
if (A[0, 2] == 0) {
amin = 1;
}
bool flag = true;
for (var i = 1; i < N; i++) {
if (A[i, 2] != 0) {
amin = Math.Max(amin, Math.Abs(it - A[i, 0]) +
Math.Abs(jt - A[i, 1]) + A[i, 2]);
}
amax = Math.Min(amax, Math.Abs(it - A[i, 0]) + Math.Abs(jt - A[i, 1]) +
A[i, 2]);
if (amin > amax) {
flag = false;
break;
}
}
if (amin != amax) {
flag = false;
}
if (flag == true) {
for (var i = 0; i < N; i++) {
if (amin - (Math.Abs(it - A[i, 0]) + Math.Abs(jt - A[i, 1])) !=
Math.Max(0, A[i, 2])) {
flag = false;
break;
}
}
}
if (flag == true) {
Console.WriteLine(it + " " + jt + " " + amin);
break;
}
jt += 1;
if (jt >= 101) {
it += 1;
if (it >= 101) {
break;
}
jt = 0;
}
}
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long[,] A = new long[N, 3];
for (var i = 0; i < N; i++) {
string[] str = Console.ReadLine().Split();
A[i, 0] = long.Parse(str[0]);
A[i, 1] = long.Parse(str[1]);
A[i, 2] = long.Parse(str[2]);
}
long it = 0;
long jt = 0;
while (true) {
long amin = Math.Abs(it - A[0, 0]) + Math.Abs(jt - A[0, 1]) + A[0, 2];
long amax = Math.Abs(it - A[0, 0]) + Math.Abs(jt - A[0, 1]) + A[0, 2];
if (A[0, 2] == 0) {
amin = 1;
}
bool flag = true;
for (var i = 1; i < N; i++) {
if (A[i, 2] != 0) {
amin = Math.Max(amin, Math.Abs(it - A[i, 0]) +
Math.Abs(jt - A[i, 1]) + A[i, 2]);
}
amax = Math.Min(amax, Math.Abs(it - A[i, 0]) + Math.Abs(jt - A[i, 1]) +
A[i, 2]);
if (amin > amax) {
flag = false;
break;
}
}
if (amin != amax) {
flag = false;
}
if (flag == true) {
for (var i = 0; i < N; i++) {
if (Math.Max(0, amin - (Math.Abs(it - A[i, 0]) +
Math.Abs(jt - A[i, 1]))) != A[i, 2]) {
flag = false;
break;
}
}
}
if (flag == true) {
Console.WriteLine(it + " " + jt + " " + amin);
break;
}
jt += 1;
if (jt >= 101) {
it += 1;
if (it >= 101) {
break;
}
jt = 0;
}
}
}
}
|
[["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 21], ["+", 12, 23, 0, 16, 12, 213, 3, 4, 0, 25], ["-", 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], ["-", 15, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 57, 15, 16, 12, 213, 3, 4, 0, 21], ["-", 0, 57, 15, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 531
| 14
|
using System;
using System.Linq; //ใชในใใฎไฝฟ็จ
using System.Collections.Generic;
class Program {
static void Main() {
long n = long.Parse(Console.ReadLine()); // int.Parseใฏๆๅญๅใๆดๆฐใซๅคๆใ
long heightMemo = 0;
long[] answer = new long[3];
long[,] vertexes = new long[n, 3]; //ใใใซๅใๅใ
long checkOk = 0;
for (long i = 0; i < n; i++) {
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),
long.Parse); //๏ผ่กใใจใซๅใๅใ
vertexes[i, 0] = nums[0];
vertexes[i, 1] = nums[1];
vertexes[i, 2] = nums[2];
}
for (long i = 0; i <= 100; i++) {
for (long j = 0; j <= 100; j++) {
for (long k = 0; k < n; k++) {
if (checkOk == 0 && vertexes[k, 2] != 0) {
heightMemo = vertexes[k, 2] + (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j));
checkOk = 1;
} else if ((vertexes[k, 2] !=
heightMemo - (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j)) &&
heightMemo - (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j)) >
0) ||
(vertexes[k, 2] != 0 &&
heightMemo - (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j)) <=
0))
break;
if (k == n - 1 && heightMemo >= 1) {
answer[0] = i;
answer[1] = j;
answer[2] = heightMemo;
}
}
}
}
Console.WriteLine(answer[0] + " " + answer[1] + " " + answer[2]);
}
}
|
using System;
using System.Linq; //ใชในใใฎไฝฟ็จ
using System.Collections.Generic;
class Program {
static void Main() {
long n = long.Parse(Console.ReadLine()); // int.Parseใฏๆๅญๅใๆดๆฐใซๅคๆใ
long heightMemo = 0;
long[] answer = new long[3];
long[,] vertexes = new long[n, 3]; //ใใใซๅใๅใ
long checkOk = 0;
for (long i = 0; i < n; i++) {
long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),
long.Parse); //๏ผ่กใใจใซๅใๅใ
vertexes[i, 0] = nums[0];
vertexes[i, 1] = nums[1];
vertexes[i, 2] = nums[2];
}
for (long i = 0; i <= 100; i++) {
for (long j = 0; j <= 100; j++) {
checkOk = 0;
for (long k = 0; k < n; k++) {
if (checkOk == 0 && vertexes[k, 2] != 0) {
heightMemo = vertexes[k, 2] + (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j));
checkOk = 1;
} else if ((checkOk == 1 &&
vertexes[k, 2] !=
heightMemo - (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j)) &&
heightMemo - (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j)) >
0) ||
(checkOk == 1 && vertexes[k, 2] != 0 &&
heightMemo - (Math.Abs(vertexes[k, 0] - i) +
Math.Abs(vertexes[k, 1] - j)) <=
0))
break;
if (k == n - 1 && heightMemo >= 1) {
answer[0] = i;
answer[1] = j;
answer[2] = heightMemo;
}
}
}
}
Console.WriteLine(answer[0] + " " + answer[1] + " " + answer[2]);
}
}
|
[["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 31, 22], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 17, 60], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 12, 203], ["+", 15, 16, 31, 23, 0, 16, 31, 16, 17, 98], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 31, 22], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 17, 60], ["+", 12, 23, 0, 16, 31, 16, 31, 16, 12, 203], ["+", 15, 16, 12, 23, 0, 16, 31, 16, 17, 98]]
| 8
| 454
| 12
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
int inputCount = int.Parse(Reader.ReadLine());
for (int i = 0; i < inputCount; i++) {
Elements.Add(new Piramix(Reader.ReadLine()));
}
Elements = Elements.OrderByDescending(a => a.Height).ToList();
int xMin = Elements[0].X;
int xMax = Elements[0].X;
int yMin = Elements[0].Y;
int yMax = Elements[0].Y;
for (int i = 0; i < Elements.Count; i++) {
if (Elements[i].Height == Elements[0].Height) {
continue;
}
if (Elements[0].X > Elements[i].X) {
if (Elements[0].X == xMin) {
xMin = Elements[i].X;
}
} else if (Elements[0].X < Elements[i].X) {
if (Elements[0].X == xMax) {
xMax = Elements[i].X;
}
}
if (Elements[0].Y > Elements[i].Y) {
if (Elements[0].Y == yMin) {
yMin = Elements[i].Y;
}
} else if (Elements[0].Y < Elements[i].Y) {
if (Elements[0].Y == yMax) {
yMax = Elements[i].Y;
}
}
if (Elements[0].X != xMin && Elements[0].X != xMax &&
Elements[0].Y != yMin && Elements[0].Y != yMax) {
break;
}
}
if (xMax == Elements[0].X) {
xMax = 100;
}
if (xMin == Elements[0].X) {
xMin = 0;
}
if (yMax == Elements[0].Y) {
yMax = 100;
}
if (yMin == Elements[0].Y) {
yMin = 0;
}
for (int i = xMin; i <= xMax; i++) {
for (int j = yMin; j <= yMax; j++) {
long height = Elements[0].Height + Math.Abs(Elements[0].X - i) +
Math.Abs(Elements[0].Y - j);
bool isMatch = true;
for (int k = 1; k < Elements.Count; k++) {
long h = Elements[k].Height + Math.Abs(Elements[k].X - i) +
Math.Abs(Elements[k].Y - j);
if (Elements[k].Height <= 0) {
if (h >= height) {
continue;
}
} else if (h == height) {
continue;
}
isMatch = false;
break;
}
if (isMatch) {
Console.WriteLine(i + " " + j + " " + height);
break;
}
}
}
}
private List<Piramix> Elements = new List<Piramix>();
private class Piramix {
public int X;
public int Y;
public long Height;
public Piramix(string inpt) {
long[] tmp = inpt.Split(' ').Select(a => long.Parse(a)).ToArray();
this.X = (int)tmp[0];
this.Y = (int)tmp[1];
this.Height = tmp[2];
}
}
public class Reader {
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
2
0 0 100
1 1 98
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
int inputCount = int.Parse(Reader.ReadLine());
for (int i = 0; i < inputCount; i++) {
Elements.Add(new Piramix(Reader.ReadLine()));
}
Elements = Elements.OrderByDescending(a => a.Height).ToList();
int xMin = Elements[0].X;
int xMax = Elements[0].X;
int yMin = Elements[0].Y;
int yMax = Elements[0].Y;
for (int i = 0; i < Elements.Count; i++) {
if (Elements[i].Height == Elements[0].Height) {
continue;
}
if (Elements[0].X > Elements[i].X) {
if (Elements[0].X == xMin) {
xMin = Elements[i].X;
}
} else if (Elements[0].X < Elements[i].X) {
if (Elements[0].X == xMax) {
xMax = Elements[i].X;
}
}
if (Elements[0].Y > Elements[i].Y) {
if (Elements[0].Y == yMin) {
yMin = Elements[i].Y;
}
} else if (Elements[0].Y < Elements[i].Y) {
if (Elements[0].Y == yMax) {
yMax = Elements[i].Y;
}
}
if (Elements[0].X != xMin && Elements[0].X != xMax &&
Elements[0].Y != yMin && Elements[0].Y != yMax) {
break;
}
}
if (xMax == Elements[0].X) {
xMax = 100;
}
if (xMin == Elements[0].X) {
xMin = 0;
}
if (yMax == Elements[0].Y) {
yMax = 100;
}
if (yMin == Elements[0].Y) {
yMin = 0;
}
xMax = 100;
xMin = 0;
yMax = 100;
yMin = 0;
for (int i = xMin; i <= xMax; i++) {
for (int j = yMin; j <= yMax; j++) {
long height = Elements[0].Height + Math.Abs(Elements[0].X - i) +
Math.Abs(Elements[0].Y - j);
bool isMatch = true;
for (int k = 1; k < Elements.Count; k++) {
long h = Elements[k].Height + Math.Abs(Elements[k].X - i) +
Math.Abs(Elements[k].Y - j);
if (Elements[k].Height <= 0) {
if (h >= height) {
continue;
}
} else if (h == height) {
continue;
}
isMatch = false;
break;
}
if (isMatch) {
Console.WriteLine(i + " " + j + " " + height);
break;
}
}
}
}
private List<Piramix> Elements = new List<Piramix>();
private class Piramix {
public int X;
public int Y;
public long Height;
public Piramix(string inpt) {
long[] tmp = inpt.Split(' ').Select(a => long.Parse(a)).ToArray();
this.X = (int)tmp[0];
this.Y = (int)tmp[1];
this.Height = tmp[2];
}
}
public class Reader {
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
2
0 0 100
1 1 98
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 861
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var x = new int[N];
var y = new int[N];
var h = new int[N];
for (int i = 0; i < N; i++) {
var input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
x[i] = input[0];
y[i] = input[1];
h[i] = input[2];
}
var t = 0;
for (int i = 0; i < N; i++) {
if (h[i] > 0) {
t = i;
break;
}
}
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var H = h[t] + Math.Abs(x[t] - cx) + Math.Abs(y[t] - cy);
var suc = true;
for (int i = 0; i < N; i++) {
var tmp = h[i] + Math.Abs(x[i] - cx) + Math.Abs(y[i] - cy);
if (tmp < 0) {
if (h[i] != 0) {
suc = false;
break;
}
} else if (tmp >= 0 && tmp != H) {
suc = false;
break;
}
}
if (suc) {
Console.WriteLine(cx + " " + cy + " " + H);
return;
}
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
var x = new int[N];
var y = new int[N];
var h = new int[N];
for (int i = 0; i < N; i++) {
var input =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
x[i] = input[0];
y[i] = input[1];
h[i] = input[2];
}
var t = 0;
for (int i = 0; i < N; i++) {
if (h[i] > 0) {
t = i;
break;
}
}
for (int cx = 0; cx <= 100; cx++) {
for (int cy = 0; cy <= 100; cy++) {
var H = h[t] + Math.Abs(x[t] - cx) + Math.Abs(y[t] - cy);
var suc = true;
for (int i = 0; i < N; i++) {
var tmp = h[i] + Math.Abs(x[i] - cx) + Math.Abs(y[i] - cy);
if (H - Math.Abs(x[i] - cx) - Math.Abs(y[i] - cy) < 0) {
if (h[i] != 0) {
suc = false;
break;
}
} else if (tmp != H) {
suc = false;
break;
}
}
if (suc) {
Console.WriteLine(cx + " " + cy + " " + H);
return;
}
}
}
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 33], ["+", 31, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 31, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 31, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 31, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 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, 22], ["+", 0, 28, 0, 16, 31, 204, 206, 207, 0, 73], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 31, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 33], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 205, 22], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 12, 213, 63, 214, 141, 22], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 16, 12, 213, 3, 4, 0, 25], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 31, 22], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 20], ["-", 0, 57, 75, 57, 15, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98]]
| 8
| 391
| 30
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
// using System.Text;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
// using System.Numerics;
using static System.Math;
// using pair = Pair<int, int>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //โโโโ
readonly int mod = 1000000007;
void chmax<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
void chmin<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }
void solve() {
int N = cin.nextint;
var X = new int[N];
var Y = new int[N];
var H = new int[N];
for (int i = 0; i < N; i++) {
X[i] = cin.nextint;
Y[i] = cin.nextint;
H[i] = cin.nextint;
}
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
int minus = Abs(X[0] - i) + Abs(Y[0] - j);
bool modezero = false;
int max = minus + H[0];
if (H[0] == 0)
modezero = true;
bool flag = true;
for (int k = 1; k < N; k++) {
int m = Abs(X[k] - i) + Abs(Y[k] - j);
int t = m + H[k];
if (max != t) {
if (modezero && H[k] == 0 && t <= max) {
} else {
flag = false;
}
}
chmin(ref max, t);
if (H[k] != 0)
modezero = false;
// if (i == 2 && j == 2) WriteLine(max);
}
if (max <= 0) {
continue;
}
if (flag) {
WriteLine(i + " " + j + " " + max);
return;
}
}
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan {
get { return ReadLine().Split(); }
}
public int[] scanint {
get { return Array.ConvertAll(scan, int.Parse); }
}
public long[] scanlong {
get { return Array.ConvertAll(scan, long.Parse); }
}
public double[] scandouble {
get { return Array.ConvertAll(scan, double.Parse); }
}
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint {
get { return int.Parse(next); }
}
public long nextlong {
get { return long.Parse(next); }
}
public double nextdouble {
get { return double.Parse(next); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
// using System.Text;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
// using System.Numerics;
using static System.Math;
// using pair = Pair<int, int>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //โโโโ
readonly int mod = 1000000007;
void chmax<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
void chmin<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }
void solve() {
long N = cin.nextlong;
var X = new long[N];
var Y = new long[N];
var H = new long[N];
for (long i = 0; i < N; i++) {
X[i] = cin.nextlong;
Y[i] = cin.nextlong;
H[i] = cin.nextlong;
}
for (long i = 0; i <= 100; i++) {
for (long j = 0; j <= 100; j++) {
long minus = Abs(X[0] - i) + Abs(Y[0] - j);
bool modezero = false;
long max = minus + H[0];
if (H[0] == 0)
modezero = true;
bool flag = true;
for (long k = 1; k < N; k++) {
long m = Abs(X[k] - i) + Abs(Y[k] - j);
long t = m + H[k];
if (max != t) {
if (modezero && t <= max) {
} else if (H[k] == 0 && max <= t) {
} else {
flag = false;
}
}
chmin(ref max, t);
if (H[k] != 0)
modezero = false;
// if (i == 2 && j == 2) WriteLine(max);
}
if (max <= 0) {
continue;
}
if (flag) {
WriteLine(i + " " + j + " " + max);
return;
}
}
}
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan {
get { return ReadLine().Split(); }
}
public int[] scanint {
get { return Array.ConvertAll(scan, int.Parse); }
}
public long[] scanlong {
get { return Array.ConvertAll(scan, long.Parse); }
}
public double[] scandouble {
get { return Array.ConvertAll(scan, double.Parse); }
}
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint {
get { return int.Parse(next); }
}
public long nextlong {
get { return long.Parse(next); }
}
public double nextdouble {
get { return double.Parse(next); }
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 8, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 214, 141, 22], ["-", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 64, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 64, 196, 0, 57, 15, 16, 12, 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, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 75, 57, 0, 24], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 64, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 19], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 723
| 45
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
// var N = long.Parse(Console.ReadLine());
var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var N = NM[0];
var M = NM[1];
var ans = 1L;
for (long i = 1; i <= (long)Sqrt(M); i++) {
var pair = M / i;
if (M % i == 0 && M / i >= N) {
ans = i;
}
if (M % i == 0 && M / pair >= N) {
ans = pair;
}
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
// var N = long.Parse(Console.ReadLine());
var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
var N = NM[0];
var M = NM[1];
var ans = 1L;
for (long i = 1; i <= (long)Sqrt(M); i++) {
var pair = M / i;
if (M % i == 0 && M / i >= N) {
ans = Max(i, ans);
}
if (M % i == 0 && M / pair >= N) {
ans = Max(pair, ans);
}
}
Console.WriteLine(ans);
}
}
}
|
[["+", 64, 196, 0, 1, 0, 11, 12, 213, 63, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 186
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class339 {
static void Main() {
var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = NM[0], M = NM[1];
var div = new List<int>();
int m = M;
for (int i = 1; i <= Math.Sqrt(M); i++) {
if (M % i == 0) {
div.Add(i);
div.Add(M / i);
}
}
Console.WriteLine(div.Where(x => x <= M / N).Last());
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp15 {
class Class339 {
static void Main() {
var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = NM[0], M = NM[1];
var div = new List<int>();
for (int i = 1; i <= Math.Sqrt(M); i++) {
if (M % i == 0) {
div.Add(i);
div.Add(M / i);
}
}
div.Sort();
Console.WriteLine(div.Where(x => x <= M / N).Last());
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 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, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 166
| 11
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadLong();
var M = sc.ReadLong();
var max = (double)M / N;
var ans = 1;
for (int i = 1; i * i <= M; i++) {
if (M % i != 0 || max < i)
continue;
ans = i;
}
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public 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;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var N = sc.ReadLong();
var M = sc.ReadLong();
var max = (double)M / N;
for (int i = (int)max; i >= 0; i--) {
if (M % i != 0)
continue;
Console.WriteLine(i);
return;
}
}
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 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;
}
}
|
[["-", 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, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 10, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 10, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 10, 198, 0, 200, 0, 212, 0, 74, 51, 22], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68], ["-", 0, 7, 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, 18], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 22], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 7, 8, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 619
| 32
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp34 {
class Program {
static void Main(string[] args) {
var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int A = st[0];
int B = st[1];
int C = st[2];
int cand_1 = 10 * A + B + C;
int cand_2 = A + 10 * B + C;
Console.WriteLine(Math.Max(cand_1, cand_2));
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp34 {
class Program {
static void Main(string[] args) {
var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int A = st[0];
int B = st[1];
int C = st[2];
int cand_1 = 10 * A + B + C;
int cand_2 = A + 10 * B + C;
int cand_3 = A + B + 10 * C;
Console.WriteLine(Math.Max(Math.Max(cand_1, cand_2), cand_3));
}
}
}
|
[["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 31, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 31, 203], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 17, 48], ["+", 0, 200, 0, 212, 0, 16, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 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, 25], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 133
| 18
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int A = int.Parse(input[0]);
int B = int.Parse(input[1]);
int C = int.Parse(input[2]);
int result = 0;
if (A > B && A > C) {
if (B > C) {
result = (10 * A + B) + C;
} else {
result = (10 * A + C) + B;
}
}
if (B > A && B > C) {
if (A > C) {
result = (10 * B + A) + C;
} else {
result = (10 * B + C) + A;
}
}
if (C > A && C > B) {
if (A > B) {
result = (10 * C + A) + B;
} else {
result = (10 * C + B) + A;
}
}
Console.WriteLine(result);
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int A = int.Parse(input[0]);
int B = int.Parse(input[1]);
int C = int.Parse(input[2]);
int result = 0;
if (A >= B && A >= C) {
if (B >= C) {
result = (10 * A + B) + C;
} else {
result = (10 * A + C) + B;
}
}
if (B >= A && B >= C) {
if (A >= C) {
result = (10 * B + A) + C;
} else {
result = (10 * B + C) + A;
}
}
if (C >= A && C >= B) {
if (A >= B) {
result = (10 * C + A) + B;
} else {
result = (10 * C + B) + A;
}
}
Console.WriteLine(result);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 20], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 232
| 18
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
WriteLine(solve());
// ReadKey();
}
static string solve() {
int n, m, x, y;
InputLine(out n, out m, out x, out y);
var a = ScanIntArray();
var b = ScanIntArray();
if (a.Max() < b.Min())
return "No War";
return "War";
}
public static string[] Transpos(string[] s) {
var h = s[0].Length;
var t = new string[h];
for (int i = 0; i < h; i++) {
t[i] = new string(s.Select(_ => _[i]).ToArray());
}
return t;
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
WriteLine(solve());
// ReadKey();
}
static string solve() {
int n, m, x, y;
InputLine(out n, out m, out x, out y);
var a = ScanIntArray();
var b = ScanIntArray();
if (Math.Max(x, a.Max()) < Math.Min(y, b.Min()))
return "No War";
return "War";
}
public static string[] Transpos(string[] s) {
var h = s[0].Length;
var t = new string[h];
for (int i = 0; i < h; i++) {
t[i] = new string(s.Select(_ => _[i]).ToArray());
}
return t;
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
[["+", 0, 57, 15, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 24], ["+", 15, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 31, 213, 3, 4, 0, 21], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 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], ["+", 15, 16, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 16, 12, 213, 3, 4, 0, 21]]
| 8
| 2,108
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp61 {
class Program {
static void Main(string[] args) {
var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = st[0];
int M = st[1];
int X = st[2];
int Y = st[3];
var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
var y = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x_max = x.Max();
int y_min = y.Min();
if (x_max + 1 >= y_min && X < x_max + 1 && x_max + 1 <= Y) {
Console.WriteLine("No War");
} else {
Console.WriteLine("War");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp61 {
class Program {
static void Main(string[] args) {
var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = st[0];
int M = st[1];
int X = st[2];
int Y = st[3];
var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
var y = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x_max = x.Max();
int y_min = y.Min();
if (x_max + 1 > y_min || Y < x_max + 1 || y_min < X + 1) {
Console.WriteLine("War");
} else {
Console.WriteLine("No War");
}
}
}
}
|
[["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 106], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 211
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
class Program {
static void Main() {
int[] nmxy =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int N = nmxy[0];
int M = nmxy[1];
int X = nmxy[2];
int Y = nmxy[3];
int[] xList =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int[] yList =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
if (xList.Max() < yList.Min()) {
Console.WriteLine("No War");
} else {
Console.WriteLine("War");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
class Program {
static void Main() {
int[] nmxy =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int N = nmxy[0];
int M = nmxy[1];
int X = nmxy[2];
int Y = nmxy[3];
int[] xList =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int[] yList =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int xMax = xList.Max();
int yMin = yList.Min();
if (xMax < yMin && X < yMin && xMax < Y) {
Console.WriteLine("No War");
} else {
Console.WriteLine("War");
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 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, 57, 15, 16, 31, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 221
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { ABC110_B(); }
static void ABC110_B() {
var NMXY = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = NMXY[0];
var M = NMXY[1];
var X = NMXY[2];
var Y = NMXY[3];
var xn = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var ym = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var Z = 0;
foreach (var z in xn.Concat(ym)) {
if (z > X && z <= Y && xn.All(x => x < z) && ym.All(y => y >= z))
Z = z;
}
Console.WriteLine(Z == 0 ? "War" : "No War");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { ABC110_B(); }
static void ABC110_B() {
var NMXY = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = NMXY[0];
var M = NMXY[1];
var X = NMXY[2];
var Y = NMXY[3];
var xn = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var ym = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var war = true;
foreach (var z in xn.Concat(ym)) {
if (z > X && z <= Y && xn.All(x => x < z) && ym.All(y => y >= z)) {
war = false;
break;
}
}
Console.WriteLine(war ? "War" : "No War");
}
}
}
|
[["-", 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, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 15, 22]]
| 8
| 230
| 16
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var answer = "War";
var line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var lineX =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var lineY =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int z = lineY.Min();
foreach (int x in lineX) {
if (line[2] >= z) {
break;
}
if (z > x) {
answer = "No War";
} else {
answer = "War";
break;
}
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var answer = "War";
var line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var lineX =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var lineY =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int z = lineY.Min();
foreach (int x in lineX) {
if (line[2] >= z) {
break;
}
if (line[3] < z) {
break;
}
if (z > x) {
answer = "No War";
} else {
answer = "War";
break;
}
}
Console.WriteLine(answer);
}
}
}
|
[["+", 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, 210, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 205
| 13
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static PB10004.Algorithm.Util;
namespace PB10004.Algorithm {
class Template {
static void Main(string[] args) { new B().Solve(); }
}
class A {
public void Solve() {
var array = ReadIntArray();
Array.Sort(array);
WriteLine(array[2] * 10 + array[0] + array[1]);
}
}
class B {
public void Solve() {
var array = ReadIntArray();
var X = array[2];
var Y = array[3];
var xs = ReadIntArray();
var ys = ReadIntArray();
var xmax = xs.Max();
var ymin = ys.Min();
if (xmax < ymin && (xmax <= Y && ymin > X))
WriteLine("No War");
else
WriteLine("War");
}
}
class C {
public void Solve() {}
}
class D {
public void Solve() {}
}
public static class Util {
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static int ReadInt() { return int.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArray() {
return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static long ReadLong() { return long.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static long[] ReadLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
/// <summary>
/// ไธๅฎๅคใฎๆฐๅใ็ๆใใ
/// </summary>
/// <param name="value"></param>
/// <param name="length"></param>
/// <returns></returns>
public static IEnumerable<long> ConstSeq(long value, long length) {
for (int i = 0; i < length; i++) {
yield return value;
}
}
/// <summary>
/// int้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) {
int tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// long้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) {
long tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// ๆๅคงๅ
ฌ็ดๆฐใใฆใผใฏใชใใใฎไบ้คๆณใงๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
return b == 0 ? a : Gcd(b, a % b);
}
/// <summary>
/// ๆๅฐๅ
ฌๅๆฐใๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static PB10004.Algorithm.Util;
namespace PB10004.Algorithm {
class Template {
static void Main(string[] args) { new B().Solve(); }
}
class A {
public void Solve() {
var array = ReadIntArray();
Array.Sort(array);
WriteLine(array[2] * 10 + array[0] + array[1]);
}
}
class B {
public void Solve() {
var array = ReadIntArray();
var X = array[2];
var Y = array[3];
var xs = ReadIntArray();
var ys = ReadIntArray();
var xmax = xs.Max();
var ymin = ys.Min();
if (xmax < ymin &&
((xmax + 1 <= Y && xmax + 1 > X) || (ymin > X && ymin <= Y)))
WriteLine("No War");
else
WriteLine("War");
}
}
class C {
public void Solve() {}
}
class D {
public void Solve() {}
}
public static class Util {
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static int ReadInt() { return int.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArray() {
return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static long ReadLong() { return long.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static long[] ReadLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
/// <summary>
/// ไธๅฎๅคใฎๆฐๅใ็ๆใใ
/// </summary>
/// <param name="value"></param>
/// <param name="length"></param>
/// <returns></returns>
public static IEnumerable<long> ConstSeq(long value, long length) {
for (int i = 0; i < length; i++) {
yield return value;
}
}
/// <summary>
/// int้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) {
int tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// long้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) {
long tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// ๆๅคงๅ
ฌ็ดๆฐใใฆใผใฏใชใใใฎไบ้คๆณใงๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
return b == 0 ? a : Gcd(b, a % b);
}
/// <summary>
/// ๆๅฐๅ
ฌๅๆฐใๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
}
|
[["+", 15, 16, 12, 23, 0, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 17, 72], ["+", 31, 23, 0, 16, 31, 16, 31, 16, 12, 203], ["+", 31, 23, 0, 16, 12, 16, 31, 16, 31, 22], ["+", 31, 23, 0, 16, 12, 16, 31, 16, 17, 72], ["+", 31, 23, 0, 16, 12, 16, 31, 16, 12, 203], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 17, 47], ["+", 0, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["+", 15, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 57, 15, 16, 12, 23, 0, 16, 17, 106], ["+", 15, 16, 12, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 23, 0, 16, 12, 23, 0, 16, 17, 98], ["+", 0, 16, 12, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 16, 12, 23, 0, 16, 12, 16, 17, 19], ["+", 0, 16, 12, 23, 0, 16, 12, 16, 12, 22], ["+", 15, 16, 12, 23, 0, 16, 12, 23, 0, 25]]
| 8
| 543
| 16
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var T = Console.ReadLine();
var map = new Dictionary<char, char>();
for (int i = 0; i < S.Length; i++) {
var s = S[i];
var t = T[i];
if (map.ContainsKey(s)) {
if (map[s] != t) {
Console.WriteLine("No");
return;
}
} else {
map.Add(s, t);
}
if (map.ContainsKey(t)) {
if (map[t] != s) {
Console.WriteLine("No");
return;
}
} else {
map.Add(t, s);
}
}
Console.WriteLine("Yes");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var T = Console.ReadLine();
var sMap = new Dictionary<char, char>();
var tMap = new Dictionary<char, char>();
for (int i = 0; i < S.Length; i++) {
var s = S[i];
var t = T[i];
if (sMap.ContainsKey(s)) {
if (sMap[s] != t) {
Console.WriteLine("No");
return;
}
} else {
sMap.Add(s, t);
}
if (tMap.ContainsKey(t)) {
if (tMap[t] != s) {
Console.WriteLine("No");
return;
}
} else {
tMap.Add(t, s);
}
}
Console.WriteLine("Yes");
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 230, 0, 228], ["+", 0, 200, 0, 212, 0, 230, 39, 236, 141, 22], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 21], ["+", 0, 212, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 24], ["+", 0, 200, 0, 212, 0, 230, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 57, 15, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 57, 15, 213, 63, 214, 205, 22], ["-", 64, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 64, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["-", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 196, 0, 1, 0, 213, 63, 214, 205, 22]]
| 8
| 194
| 27
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
namespace AtCoder {
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)1e9 + 7;
static void Main(string[] args) {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
Read();
}
static void Solve() {
var NM = Sarray();
var N = NM[0];
var M = NM[1];
var cmb = new Combination(2 * N, Mod);
var dct = primefactorize(M);
var ans = 1L;
foreach (var d in dct)
ans = ans * cmb.nCk((int)(N - 1 + d.Value), (int)d.Value) % Mod;
WriteLine(ans);
}
static Dictionary<long, long> primefactorize(long n) {
var primes = new Dictionary<long, long>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (primes.ContainsKey(i))
++primes[i];
else
primes[i] = 1;
n /= i;
}
}
if (n != 1)
primes[n] = 1;
return primes;
}
public class Combination {
readonly long mod;
readonly long[] fac, finv, inv;
public Combination(long n, long mod = 1000000007) {
long max = n + 1;
this.mod = mod;
fac = new long[max];
finv = new long[max];
inv = new long[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; ++i) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
public long nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 | k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
namespace AtCoder {
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)1e9 + 7;
static void Main(string[] args) {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
Read();
}
static void Solve() {
var NM = Sarray();
var N = NM[0];
var M = NM[1];
var cmb = new Combination(2 * 100000, Mod);
var dct = primefactorize(M);
var ans = 1L;
foreach (var d in dct)
ans = ans * cmb.nCk((int)(N - 1 + d.Value), (int)d.Value) % Mod;
WriteLine(ans);
}
static Dictionary<long, long> primefactorize(long n) {
var primes = new Dictionary<long, long>();
for (long i = 2; i * i <= n; ++i) {
while (n % i == 0) {
if (!primes.ContainsKey(i))
primes[i] = 0;
++primes[i];
n /= i;
}
}
if (n != 1)
primes[n] = 1;
return primes;
}
public class Combination {
readonly long mod;
readonly long[] fac, finv, inv;
public Combination(long n, long mod = 1000000007) {
long max = n + 1;
this.mod = mod;
fac = new long[max];
finv = new long[max];
inv = new long[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; ++i) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
public long nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 | k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
}
}
}
|
[["-", 0, 230, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 230, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 57, 15, 241, 0, 111], ["-", 8, 196, 0, 57, 64, 1, 0, 241, 0, 29], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 52, 8, 196, 0, 57, 0, 95], ["+", 0, 52, 8, 196, 0, 1, 0, 241, 0, 29], ["-", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["-", 8, 196, 0, 57, 75, 1, 0, 11, 12, 203]]
| 8
| 591
| 10
|
using System;
namespace debug {
class Program {
static void Main(string[] args) {
ProgramD a = new ProgramD();
a.main();
}
}
// ABC110
class ProgramA {
public void main() {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
class ProgramB {
public void main() {
long n = long.Parse(Console.ReadLine());
for (long i = 1; i < 100000; i++) {
if (i * i > n) {
Console.WriteLine((i - 1) * (i - 1));
return;
}
}
}
}
class ProgramC {
public void main() {
string s = Console.ReadLine();
string t = Console.ReadLine();
Console.WriteLine();
}
}
// ACใใฆใชใใงใใ
class ProgramD {
public void main() {
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long m = long.Parse(s[1]);
long t = m;
long count = 0;
long[] fac = new long[n + 1];
for (long i = 2; i <= Math.Sqrt(m); i++) {
if (t % i == 0) {
while (t % i == 0) {
t /= i;
fac[count]++;
}
count++;
}
}
if (t != 1) {
fac[count]++;
count++;
}
long MOD = 1000000000 + 7;
long sum = 1;
//ไธๆบๅ
nCk com = new nCk();
com.fac = new long[n + 50];
com.inv = new long[n + 50];
com.finv = new long[n + 50];
com.mod = MOD;
com.max = n + 50;
//ใกใขไฝๆ
com.com_init();
for (int i = 0; i < count; i++) {
if (n == 1)
sum *= fac[i] + 1;
else
sum *= com.com(n + fac[i] - 1, fac[i]);
sum %= MOD;
}
Console.WriteLine(sum);
}
}
class nCk {
public long mod;
public long max;
public long[] fac;
public long[] inv;
public long[] finv;
//ใกใขไฝๆ(ๅๆบๅ)
public void com_init() {
fac[0] = 1;
fac[1] = 1;
finv[0] = 1;
finv[1] = 1;
inv[1] = 1;
for (long i = 2; i < max; i++) {
fac[i] = i * fac[i - 1] % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
//ไบ้
่จ็ฎ
public long com(long n, long k) {
if (n < 0 || k < 0)
return 0;
if (n < k)
return 0;
return fac[n] * (finv[n - k] * finv[k] % mod) % mod;
}
}
}
|
using System;
namespace debug {
class Program {
static void Main(string[] args) {
ProgramD a = new ProgramD();
a.main();
}
}
// ABC110
class ProgramA {
public void main() {
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
if (s1[0] == s2[2] && s1[1] == s2[1] && s1[2] == s2[0])
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
class ProgramB {
public void main() {
long n = long.Parse(Console.ReadLine());
for (long i = 1; i < 100000; i++) {
if (i * i > n) {
Console.WriteLine((i - 1) * (i - 1));
return;
}
}
}
}
class ProgramC {
public void main() {
string s = Console.ReadLine();
string t = Console.ReadLine();
Console.WriteLine();
}
}
// ACใใฆใชใใงใใ
class ProgramD {
public void main() {
string[] s = Console.ReadLine().Split(' ');
long n = long.Parse(s[0]);
long m = long.Parse(s[1]);
long t = m;
long count = 0;
long[] fac = new long[n + 1];
for (long i = 2; i <= Math.Sqrt(m); i++) {
if (t % i == 0) {
while (t % i == 0) {
t /= i;
fac[count]++;
}
count++;
}
}
if (t != 1) {
fac[count]++;
count++;
}
long MOD = 1000000000 + 7;
long sum = 1;
//ไธๆบๅ
nCk com = new nCk();
com.fac = new long[n + 50];
com.inv = new long[n + 50];
com.finv = new long[n + 50];
com.mod = MOD;
com.max = n + 50;
//ใกใขไฝๆ
com.com_init();
for (int i = 0; i < count; i++) {
sum *= com.com(n + fac[i] - 1, fac[i]);
sum %= MOD;
}
Console.WriteLine(sum);
}
}
class nCk {
public long mod;
public long max;
public long[] fac;
public long[] inv;
public long[] finv;
//ใกใขไฝๆ(ๅๆบๅ)
public void com_init() {
fac[0] = 1;
fac[1] = 1;
finv[0] = 1;
finv[1] = 1;
inv[1] = 1;
for (long i = 2; i < max; i++) {
fac[i] = i * fac[i - 1] % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
//ไบ้
่จ็ฎ
public long com(long n, long k) {
if (n < 0 || k < 0)
return 0;
if (n < k)
return 0;
return fac[n] * (finv[n - k] * finv[k] % mod) % mod;
}
}
}
|
[["-", 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, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 1, 0, 11, 0, 202, 0, 108], ["-", 64, 1, 0, 11, 12, 16, 31, 204, 205, 22], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 70], ["-", 12, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 11, 12, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 57, 64, 1, 0, 11, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
| 8
| 719
| 16
|
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;
namespace ABC110D {
class Program {
static int n;
static void Main(string[] args) {
n = RInt;
var m = RInt;
var primes = PrimeNumbers(100000);
var fact = PrimeFactorization(m, primes.ToList());
//็ดๆฐใชในใ <็ดๆฐใใซใฆใณใ>
Dictionary<int, int> divs = new Dictionary<int, int>();
foreach (var f in fact) {
if (divs.ContainsKey(f))
divs[f]++;
else
divs.Add(f, 1);
}
Mlong ans = 1;
Mlong.nCkInit(100100);
foreach (var d in divs) {
int b = d.Value;
ans *= Mlong.nCk(b + n - 1, b);
}
Console.WriteLine(ans);
}
/// <summary>
/// ่ช็ถๆฐnไปฅไธใฎ็ด ๆฐprimeๅๆ (NloglogN)
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int[] PrimeNumbers(int n) {
int max = n;
var searchList = Enumerable.Range(2, max).ToList();
var pList = new List<int>();
while (searchList.Count > 0) {
int cand = searchList.First();
pList.Add(cand);
searchList.RemoveAll(x => x % cand == 0);
}
return pList.ToArray();
}
/// <summary>
/// ่ช็ถๆฐnใฎ็ด ๅ ๆฐๅ่งฃ
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int[] PrimeFactorization(int n, List<int> pList) {
int N = n;
// var pList = PrimeNumbers((int)Math.Sqrt(n)).ToList();
var ansList = new List<int>();
for (int i = 0; i < pList.Count;) {
if (N % pList[i] == 0) {
ansList.Add(pList[i]);
N /= pList[i];
} else
i++;
}
if (ansList.Count == 0 || N != 1)
ansList.Add(N);
return ansList.ToArray();
}
}
/// <summary>
/// Mod่จ็ฎๅ ่ฅๅนฒ้
ใใใ
/// </summary>
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
}
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 ABC110D {
class Program {
static int n;
static void Main(string[] args) {
n = RInt;
var m = RInt;
var primes = PrimeNumbers(100000);
var fact = PrimeFactorization(m, primes.ToList());
//็ดๆฐใชในใ <็ดๆฐใใซใฆใณใ>
Dictionary<int, int> divs = new Dictionary<int, int>();
foreach (var f in fact) {
if (divs.ContainsKey(f))
divs[f]++;
else
divs.Add(f, 1);
}
Mlong ans = 1;
Mlong.nCkInit(100100);
foreach (var d in divs) {
int b = d.Value;
ans *= Mlong.nCk(b + n - 1, b);
}
if (m == 1)
ans = 1;
Console.WriteLine(ans);
}
/// <summary>
/// ่ช็ถๆฐnไปฅไธใฎ็ด ๆฐprimeๅๆ (NloglogN)
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int[] PrimeNumbers(int n) {
int max = n;
var searchList = Enumerable.Range(2, max).ToList();
var pList = new List<int>();
while (searchList.Count > 0) {
int cand = searchList.First();
pList.Add(cand);
searchList.RemoveAll(x => x % cand == 0);
}
return pList.ToArray();
}
/// <summary>
/// ่ช็ถๆฐnใฎ็ด ๅ ๆฐๅ่งฃ
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static int[] PrimeFactorization(int n, List<int> pList) {
int N = n;
// var pList = PrimeNumbers((int)Math.Sqrt(n)).ToList();
var ansList = new List<int>();
for (int i = 0; i < pList.Count;) {
if (N % pList[i] == 0) {
ansList.Add(pList[i]);
N /= pList[i];
} else
i++;
}
if (ansList.Count == 0 || N != 1)
ansList.Add(N);
return ansList.ToArray();
}
}
/// <summary>
/// Mod่จ็ฎๅ ่ฅๅนฒ้
ใใใ
/// </summary>
public struct Mlong {
long _v;
const long mod = 1000000007;
public Mlong(long n = 0) : this() { _v = n >= mod ? n % mod : n; }
public static implicit operator Mlong(long _x) => new Mlong(_x);
public static implicit operator long(Mlong _x) => _x._v;
public static Mlong operator +(Mlong m1, Mlong m2) {
long m = m1._v + m2._v;
return m >= mod ? m - mod : m;
}
public static Mlong operator -(Mlong m1, Mlong m2) {
long m = m1._v - m2._v;
return m >= 0 ? m : m + mod;
}
public static Mlong operator *(Mlong m1, Mlong m2) => m1._v * m2._v % mod;
public static Mlong
operator /(Mlong m1, Mlong m2) => m1._v * ModPow(m2._v, mod - 2) % mod;
public static long ModPow(long a, long n) {
if (n == 0)
return 1;
else if (n % 2 == 1)
return a * ModPow(a, n - 1) % mod;
else
return ModPow(a * a, n / 2);
}
static Mlong[] fac, finv, inv;
public static void nCkInit(int max) {
fac = new Mlong[max];
finv = new Mlong[max];
inv = new Mlong[max];
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < max; i++) {
fac[i] = fac[i - 1] * i;
inv[i] = mod - inv[mod % i] * (mod / i);
finv[i] = finv[i - 1] * inv[i];
}
}
public static Mlong nCk(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * finv[k] * finv[n - k];
}
}
}
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], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 1,459
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using ll = System.Int64;
public class Contest {
static void Swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static void Swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
Swap1(ref a, ref b);
} // b ใฎๆนใๅฐใใใใฐไบคๆ
static bool Chmin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅฐใใใใฐ a ใๆดๆฐ
static bool Chmax<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅคงใใใใฐ a ใๆดๆฐ
static T[][] InitMat<T>(long len1, long len2, T val)
where T : struct {
T[][] m = new T[len1][];
for (int i = 0; i < m.Length; i++)
m[i] = Enumerable.Repeat(val, (int)len2).ToArray();
return m;
}
static T[][][] InitMat<T>(long len1, long len2, long len3, T val)
where T : struct {
T[][][] m = new T[len1][][];
for (int i = 0; i < m.Length; i++)
m[i] = InitMat(len2, len3, val);
return m;
}
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public static void Main() { Solve_D(); }
public static void Solve_A() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_B() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_C() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_D() {
long n, m;
MyIO.ReadMulti(out n, out m);
ll[] pf = PrimeFactor(m);
var ec = ElementCount(pf, 0);
long ans = 1;
ModCombination mc = new ModCombination(2 * n, MOD1);
foreach (var e in ec) {
ans = (ans * mc.H(n, e.Value).Value) % MOD1;
}
MyIO.WriteMulti(ans);
}
public static void Solve_E() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_F() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static KeyValuePair<T, long>[] ElementCount<T>(IEnumerable<T> a,
long order)
where T : IComparable {
Dictionary<T, long> d = new Dictionary<T, long>();
foreach (var e in a) {
if (!d.ContainsKey(e))
d[e] = 0;
d[e]++;
}
KeyValuePair<T, long>[] r = d.ToArray();
if (order == 1)
Array.Sort(r, (x, y) => (x.Key.CompareTo(y.Key)));
if (order == 2)
Array.Sort(r, (x, y) => (y.Key.CompareTo(x.Key)));
if (order == 3)
Array.Sort(r, (x, y) => (x.Value.CompareTo(y.Value)));
if (order == 4)
Array.Sort(r, (x, y) => (y.Value.CompareTo(x.Value)));
return r;
}
public static long[] PrimeFactor(long n) {
List<long> ret = new List<long>();
if (n < 2)
return ret.ToArray();
while ((n & 1) == 0) {
ret.Add(2);
n >>= 1;
}
while ((n % 3) == 0) {
ret.Add(3);
n /= 3;
}
long sqi = (long)Math.Sqrt(n);
while (sqi * sqi <= n)
sqi++;
for (long i = 5, f = 2; i < sqi; i += f, f ^= 6) {
while ((n % i) == 0) {
ret.Add(i);
n /= i;
}
}
if (1 < n)
ret.Add(n);
return ret.ToArray();
}
public struct ModInt {
public long Value;
public long Modulo;
public ModInt(long value) : this(value, long.MaxValue) {}
public ModInt(long value, long modulo) {
this.Modulo = modulo;
this.Value =
value >= 0 ? value % modulo : (modulo - (-value) % modulo) % modulo;
}
public static implicit operator ModInt(long v) {
return new ModInt(v, 1000000007L);
}
public static ModInt operator -(ModInt a) {
return new ModInt(-1 * a.Value, a.Modulo);
}
public static ModInt operator +(ModInt a, ModInt b) {
return new ModInt(a.Value + b.Value, a.Modulo);
}
public static ModInt operator -(ModInt a, ModInt b) {
return new ModInt(a.Value - b.Value, a.Modulo);
}
public static ModInt operator *(ModInt a, ModInt b) {
return new ModInt(a.Value * b.Value, a.Modulo);
}
public static ModInt operator /(ModInt a, ModInt b) {
return a * b.Inverse();
}
public static bool operator ==(ModInt a, ModInt b) { return a.Equals(b); }
public static bool operator !=(ModInt a, ModInt b) { return !a.Equals(b); }
public ModInt Inverse() {
long a = this.Value, b = this.Modulo, u = 1, v = 0, t, s;
while (b > 0) {
t = a / b;
s = a - t * b;
a = b;
b = s;
s = u - t * v;
u = v;
v = s;
}
return new ModInt(u, this.Modulo);
}
public ModInt Pow(long n) {
ModInt ret = new ModInt(1, this.Modulo);
ModInt mul = new ModInt(this.Value, this.Modulo);
while (n > 0) {
if ((n & 1) == 1)
ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
public override bool Equals(object obj) {
if (!(obj is ModInt))
throw new ArgumentException("Object is not a ModInt");
return Equals((ModInt)obj);
}
public bool Equals(ModInt p) => (this.Value == p.Value);
public override int GetHashCode() => (int)(this.Value ^ this.Modulo);
public override string ToString() => this.Value.ToString();
}
// nPr nCr nHr B(n,k) S{nk} P(n,k) ใๆฑใใใ
// ModCombinationใฏ็ตๆใmod โป ModInt ใฏใฉในใๅฟ
่ฆ
// ใใซๆฐ B(n,k)
// ๅบๅฅใงใใ nๅใฎใใผใซใๅบๅฅใงใใชใ
// kๅไปฅไธใฎ็ฎฑใซๅๅฒใใๆนๆณใฎๆฐใไธใใใ ็นใซ B(n,n)ใฏ n
// ๅใฎใใผใซใไปปๆๅใฎใฐใซใผใใซๅๅฒใใๆนๆณใฎๆฐใงใใใ
// ็ฌฌ2็จฎในใฟใผใชใณใฐๆฐ S{nk}
// ๅบๅฅใงใใ n ๅใฎใใผใซใๅบๅฅใงใใชใ k
// ๅใฎ็ฎฑใซๅๅฒใใๆนๆณใฎๆฐใไธใใใ
// ๅๅฒๆฐใใผใใซ
// ๅๅฒๆฐ P(n,k) ใฏๆดๆฐ n ใใกใใใฉ k
// ๅใฎ้่ฒ ๆดๆฐใฎๅใง่กจใๆนๆณใฎๆฐใไธใใใ ้ ๅบใ็ฐใชใใใฎใฏๅไธ่ฆใใใ
public class ModCombination {
private ModInt[] _fact, _rfact, _inv;
private ModInt[] _mm;
public ModCombination(long sz) : this(sz, long.MaxValue) {}
public ModCombination(long sz, long modulo) {
_fact = new ModInt[sz + 1];
_rfact = new ModInt[sz + 1];
_inv = new ModInt[sz + 1];
_mm = new ModInt[] { new ModInt(0, modulo), new ModInt(1, modulo) };
_fact[0] = _rfact[sz] = _inv[0] = _mm[1];
for (int i = 1; i <= sz; i++)
_fact[i] = _fact[i - 1] * i;
_rfact[sz] /= _fact[sz];
for (int i = (int)sz - 1; i >= 0; i--)
_rfact[i] = _rfact[i + 1] * (i + 1);
for (int i = 1; i <= sz; i++)
_inv[i] = _rfact[i] * _fact[i - 1];
}
public ModInt P(long n, long r) {
if (r < 0 || n < r)
return _mm[0];
return _fact[n] * _rfact[n - r];
}
public ModInt C(long n, long r) {
if (r < 0 || n < r)
return _mm[0];
return _fact[n] * _rfact[r] * _rfact[n - r];
}
public ModInt H(long n, long r) {
if (n < 0 || r < 0)
return _mm[0];
return r == 0 ? _mm[1] : C(n + r - 1, r);
}
public ModInt B(long n, long k) {
if (n == 0)
return _mm[1];
k = k < n ? k : n;
ModInt ret = _mm[0];
long mo = _mm[0].Modulo;
ModInt[] pref = new ModInt[k + 1];
pref[0] = _mm[1];
for (int i = 1; i <= k; i++) {
if ((i & 1) == 1)
pref[i] = pref[i - 1] - _rfact[i];
else
pref[i] = pref[i - 1] + _rfact[i];
}
for (int i = 1; i <= k; i++)
ret += (new ModInt(i, mo)).Pow(n) * _rfact[i] * pref[k - i];
return ret;
}
public ModInt S(long n, long k) {
ModInt ret = _mm[0];
long mo = _mm[0].Modulo;
for (int i = 0; i <= k; i++) {
var add = (new ModInt(i, mo)).Pow(n) * this.C(k, i);
if (((k - i) & 1) == 1)
ret -= add;
else
ret += add;
}
return ret * _rfact[k];
}
public static ModInt[][] PartitionTable(long n, long k,
long modulo = long.MaxValue) {
ModInt[][] dp = new ModInt[n + 1][];
for (int i = 0; i <= n; i++)
dp[i] = new ModInt[k + 1];
dp[0][0] = new ModInt(1, modulo);
for (int i = 0; i <= n; i++) {
for (int j = 1; j <= k; j++) {
if (i - j >= 0)
dp[i][j] = dp[i][j - 1] + dp[i - j][j];
else
dp[i][j] = dp[i][j - 1];
}
}
return dp;
}
}
}
#region MyIO
public struct VT<T, U> {
public T Item1;
public U Item2;
public VT(T a, U b) {
Item1 = a;
Item2 = b;
}
}
public struct VT<T, U, V> {
public T Item1;
public U Item2;
public V Item3;
public VT(T a, U b, V c) {
Item1 = a;
Item2 = b;
Item3 = c;
}
}
public struct VT<T, U, V, W> {
public T Item1;
public U Item2;
public V Item3;
public W Item4;
public VT(T a, U b, V c, W d) {
Item1 = a;
Item2 = b;
Item3 = c;
Item4 = d;
}
}
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
public static class MyIO {
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private static 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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c,
out W d, out X e,
out Y f) {
var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(long n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
a = new VT<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new VT<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
a = new VT<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new VT<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadLines<T, U, V, W>(long n,
out VT<T, U, V, W>[] a) {
a = new VT<T, U, V, W>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
arr[i] = ReadMulti(out o, out p, out q, out r);
a[i] = new VT<T, U, V, W>(o, p, q, r);
}
return arr;
}
public static string[][] ReadMatrix<T>(long n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
private static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}"
: "{0}";
public static void WriteMulti(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length; i++) {
string fs = wfm(a[i].GetType()) +
((i < a.Length - 1) ? " " : Environment.NewLine);
Console.Write(fs, a[i]);
}
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T));
string fs1 = fs + " ";
string fs2 = fs + Environment.NewLine;
for (int i = 0; i < a.Length; i++)
Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]);
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T)) + Environment.NewLine;
foreach (T x in a)
Console.Write(fs, x);
});
}
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// using System.Numerics;
using System.Runtime.CompilerServices;
using ll = System.Int64;
public class Contest {
static void Swap1<T>(ref T a, ref T b) {
T t = a;
a = b;
b = t;
}
static void Swap2<T>(ref T a, ref T b)
where T : IComparable {
if (a.CompareTo(b) == 1)
Swap1(ref a, ref b);
} // b ใฎๆนใๅฐใใใใฐไบคๆ
static bool Chmin<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == 1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅฐใใใใฐ a ใๆดๆฐ
static bool Chmax<T>(ref T a, T b)
where T : IComparable {
if (a.CompareTo(b) == -1) {
a = b;
return true;
}
return false;
} // b ใฎๆนใๅคงใใใใฐ a ใๆดๆฐ
static T[][] InitMat<T>(long len1, long len2, T val)
where T : struct {
T[][] m = new T[len1][];
for (int i = 0; i < m.Length; i++)
m[i] = Enumerable.Repeat(val, (int)len2).ToArray();
return m;
}
static T[][][] InitMat<T>(long len1, long len2, long len3, T val)
where T : struct {
T[][][] m = new T[len1][][];
for (int i = 0; i < m.Length; i++)
m[i] = InitMat(len2, len3, val);
return m;
}
public const long MOD1 = 1000000007; // 10^9+7
public const double EPS1 = 1e-8;
public static void Main() { Solve_D(); }
public static void Solve_A() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_B() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_C() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_D() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 1;
if (1 < m && 1 < n) {
ll[] pf = PrimeFactor(m);
var ec = ElementCount(pf, 0);
ModCombination mc = new ModCombination(2 * n + 2, MOD1);
foreach (var e in ec) {
ans = (ans * mc.H(n, e.Value).Value) % MOD1;
}
}
MyIO.WriteMulti(ans);
}
public static void Solve_E() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static void Solve_F() {
long n, m;
MyIO.ReadMulti(out n, out m);
long ans = 0;
MyIO.WriteMulti(ans);
}
public static KeyValuePair<T, long>[] ElementCount<T>(IEnumerable<T> a,
long order)
where T : IComparable {
Dictionary<T, long> d = new Dictionary<T, long>();
foreach (var e in a) {
if (!d.ContainsKey(e))
d[e] = 0;
d[e]++;
}
KeyValuePair<T, long>[] r = d.ToArray();
if (order == 1)
Array.Sort(r, (x, y) => (x.Key.CompareTo(y.Key)));
if (order == 2)
Array.Sort(r, (x, y) => (y.Key.CompareTo(x.Key)));
if (order == 3)
Array.Sort(r, (x, y) => (x.Value.CompareTo(y.Value)));
if (order == 4)
Array.Sort(r, (x, y) => (y.Value.CompareTo(x.Value)));
return r;
}
public static long[] PrimeFactor(long n) {
List<long> ret = new List<long>();
if (n < 2)
return ret.ToArray();
while ((n & 1) == 0) {
ret.Add(2);
n >>= 1;
}
while ((n % 3) == 0) {
ret.Add(3);
n /= 3;
}
long sqi = (long)Math.Sqrt(n);
while (sqi * sqi <= n)
sqi++;
for (long i = 5, f = 2; i < sqi; i += f, f ^= 6) {
while ((n % i) == 0) {
ret.Add(i);
n /= i;
}
}
if (1 < n)
ret.Add(n);
return ret.ToArray();
}
public struct ModInt {
public long Value;
public long Modulo;
public ModInt(long value) : this(value, long.MaxValue) {}
public ModInt(long value, long modulo) {
this.Modulo = modulo;
this.Value =
value >= 0 ? value % modulo : (modulo - (-value) % modulo) % modulo;
}
public static implicit operator ModInt(long v) {
return new ModInt(v, 1000000007L);
}
public static ModInt operator -(ModInt a) {
return new ModInt(-1 * a.Value, a.Modulo);
}
public static ModInt operator +(ModInt a, ModInt b) {
return new ModInt(a.Value + b.Value, a.Modulo);
}
public static ModInt operator -(ModInt a, ModInt b) {
return new ModInt(a.Value - b.Value, a.Modulo);
}
public static ModInt operator *(ModInt a, ModInt b) {
return new ModInt(a.Value * b.Value, a.Modulo);
}
public static ModInt operator /(ModInt a, ModInt b) {
return a * b.Inverse();
}
public static bool operator ==(ModInt a, ModInt b) { return a.Equals(b); }
public static bool operator !=(ModInt a, ModInt b) { return !a.Equals(b); }
public ModInt Inverse() {
long a = this.Value, b = this.Modulo, u = 1, v = 0, t, s;
while (b > 0) {
t = a / b;
s = a - t * b;
a = b;
b = s;
s = u - t * v;
u = v;
v = s;
}
return new ModInt(u, this.Modulo);
}
public ModInt Pow(long n) {
ModInt ret = new ModInt(1, this.Modulo);
ModInt mul = new ModInt(this.Value, this.Modulo);
while (n > 0) {
if ((n & 1) == 1)
ret *= mul;
mul *= mul;
n >>= 1;
}
return ret;
}
public override bool Equals(object obj) {
if (!(obj is ModInt))
throw new ArgumentException("Object is not a ModInt");
return Equals((ModInt)obj);
}
public bool Equals(ModInt p) => (this.Value == p.Value);
public override int GetHashCode() => (int)(this.Value ^ this.Modulo);
public override string ToString() => this.Value.ToString();
}
// nPr nCr nHr B(n,k) S{nk} P(n,k) ใๆฑใใใ
// ModCombinationใฏ็ตๆใmod โป ModInt ใฏใฉในใๅฟ
่ฆ
// ใใซๆฐ B(n,k)
// ๅบๅฅใงใใ nๅใฎใใผใซใๅบๅฅใงใใชใ
// kๅไปฅไธใฎ็ฎฑใซๅๅฒใใๆนๆณใฎๆฐใไธใใใ ็นใซ B(n,n)ใฏ n
// ๅใฎใใผใซใไปปๆๅใฎใฐใซใผใใซๅๅฒใใๆนๆณใฎๆฐใงใใใ
// ็ฌฌ2็จฎในใฟใผใชใณใฐๆฐ S{nk}
// ๅบๅฅใงใใ n ๅใฎใใผใซใๅบๅฅใงใใชใ k
// ๅใฎ็ฎฑใซๅๅฒใใๆนๆณใฎๆฐใไธใใใ
// ๅๅฒๆฐใใผใใซ
// ๅๅฒๆฐ P(n,k) ใฏๆดๆฐ n ใใกใใใฉ k
// ๅใฎ้่ฒ ๆดๆฐใฎๅใง่กจใๆนๆณใฎๆฐใไธใใใ ้ ๅบใ็ฐใชใใใฎใฏๅไธ่ฆใใใ
public class ModCombination {
private ModInt[] _fact, _rfact, _inv;
private ModInt[] _mm;
public ModCombination(long sz) : this(sz, long.MaxValue) {}
public ModCombination(long sz, long modulo) {
_fact = new ModInt[sz + 1];
_rfact = new ModInt[sz + 1];
_inv = new ModInt[sz + 1];
_mm = new ModInt[] { new ModInt(0, modulo), new ModInt(1, modulo) };
_fact[0] = _rfact[sz] = _inv[0] = _mm[1];
for (int i = 1; i <= sz; i++)
_fact[i] = _fact[i - 1] * i;
_rfact[sz] /= _fact[sz];
for (int i = (int)sz - 1; i >= 0; i--)
_rfact[i] = _rfact[i + 1] * (i + 1);
for (int i = 1; i <= sz; i++)
_inv[i] = _rfact[i] * _fact[i - 1];
}
public ModInt P(long n, long r) {
if (r < 0 || n < r)
return _mm[0];
return _fact[n] * _rfact[n - r];
}
public ModInt C(long n, long r) {
if (r < 0 || n < r)
return _mm[0];
return _fact[n] * _rfact[r] * _rfact[n - r];
}
public ModInt H(long n, long r) {
if (n < 0 || r < 0)
return _mm[0];
return r == 0 ? _mm[1] : C(n + r - 1, r);
}
public ModInt B(long n, long k) {
if (n == 0)
return _mm[1];
k = k < n ? k : n;
ModInt ret = _mm[0];
long mo = _mm[0].Modulo;
ModInt[] pref = new ModInt[k + 1];
pref[0] = _mm[1];
for (int i = 1; i <= k; i++) {
if ((i & 1) == 1)
pref[i] = pref[i - 1] - _rfact[i];
else
pref[i] = pref[i - 1] + _rfact[i];
}
for (int i = 1; i <= k; i++)
ret += (new ModInt(i, mo)).Pow(n) * _rfact[i] * pref[k - i];
return ret;
}
public ModInt S(long n, long k) {
ModInt ret = _mm[0];
long mo = _mm[0].Modulo;
for (int i = 0; i <= k; i++) {
var add = (new ModInt(i, mo)).Pow(n) * this.C(k, i);
if (((k - i) & 1) == 1)
ret -= add;
else
ret += add;
}
return ret * _rfact[k];
}
public static ModInt[][] PartitionTable(long n, long k,
long modulo = long.MaxValue) {
ModInt[][] dp = new ModInt[n + 1][];
for (int i = 0; i <= n; i++)
dp[i] = new ModInt[k + 1];
dp[0][0] = new ModInt(1, modulo);
for (int i = 0; i <= n; i++) {
for (int j = 1; j <= k; j++) {
if (i - j >= 0)
dp[i][j] = dp[i][j - 1] + dp[i - j][j];
else
dp[i][j] = dp[i][j - 1];
}
}
return dp;
}
}
}
#region MyIO
public struct VT<T, U> {
public T Item1;
public U Item2;
public VT(T a, U b) {
Item1 = a;
Item2 = b;
}
}
public struct VT<T, U, V> {
public T Item1;
public U Item2;
public V Item3;
public VT(T a, U b, V c) {
Item1 = a;
Item2 = b;
Item3 = c;
}
}
public struct VT<T, U, V, W> {
public T Item1;
public U Item2;
public V Item3;
public W Item4;
public VT(T a, U b, V c, W d) {
Item1 = a;
Item2 = b;
Item3 = c;
Item4 = d;
}
}
public class Printer : System.IO.StreamWriter {
public override IFormatProvider FormatProvider {
get { return System.Globalization.CultureInfo.InvariantCulture; }
}
public Printer(System.IO.Stream stream)
: base(stream, new UTF8Encoding(false, true)) {}
public Printer(System.IO.Stream stream, Encoding encoding)
: base(stream, encoding) {}
}
public static class MyIO {
private static char[] splitter = new char[] { ' ' };
private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
private static 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, System.Globalization.CultureInfo.InvariantCulture))
: eq<T, char>() ? ct<T, char>(s[0])
: ct<T, string>(s);
public static string[] ReadMulti<T>(out T a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = cv<T>(ar[0]);
return ar;
}
public static string[] ReadMulti<T, U>(out T a, out U b) {
var ar = ReadMulti<T>(out a);
b = cv<U>(ar[1]);
return ar;
}
public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
var ar = ReadMulti<T, U>(out a, out b);
c = cv<V>(ar[2]);
return ar;
}
public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c,
out W d) {
var ar = ReadMulti<T, U, V>(out a, out b, out c);
d = cv<W>(ar[3]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c,
out W d, out X e) {
var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d);
e = cv<X>(ar[4]);
return ar;
}
public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c,
out W d, out X e,
out Y f) {
var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e);
f = cv<Y>(ar[5]);
return ar;
}
public static string[] ReadArray<T>(out T[] a) {
var ar = Console.ReadLine().Split(splitter,
StringSplitOptions.RemoveEmptyEntries);
a = ar.Select(cv<T>).ToArray();
return ar;
}
public static string[][] ReadLines<T>(long n, out T[] a) {
a = new T[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadMulti(out a[i]);
return arr;
}
public static string[][] ReadLines<T, U>(long n, out VT<T, U>[] a) {
a = new VT<T, U>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
arr[i] = ReadMulti(out o, out p);
a[i] = new VT<T, U>(o, p);
}
return arr;
}
public static string[][] ReadLines<T, U, V>(long n, out VT<T, U, V>[] a) {
a = new VT<T, U, V>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
arr[i] = ReadMulti(out o, out p, out q);
a[i] = new VT<T, U, V>(o, p, q);
}
return arr;
}
public static string[][] ReadLines<T, U, V, W>(long n,
out VT<T, U, V, W>[] a) {
a = new VT<T, U, V, W>[n];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++) {
T o;
U p;
V q;
W r;
arr[i] = ReadMulti(out o, out p, out q, out r);
a[i] = new VT<T, U, V, W>(o, p, q, r);
}
return arr;
}
public static string[][] ReadMatrix<T>(long n, out T[][] a) {
a = new T[n][];
string[][] arr = new string[n][];
for (int i = 0; i < n; i++)
arr[i] = ReadArray(out a[i]);
return arr;
}
private static void wwp(Action act) {
var sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
act();
Console.Out.Flush();
sw.AutoFlush = true;
Console.SetOut(sw);
}
private static string wfm(Type t) => t.Equals(typeof(double)) ? "{0:F10}"
: "{0}";
public static void WriteMulti(params object[] a) {
wwp(() => {
for (int i = 0; i < a.Length; i++) {
string fs = wfm(a[i].GetType()) +
((i < a.Length - 1) ? " " : Environment.NewLine);
Console.Write(fs, a[i]);
}
});
}
public static void WriteArray<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T));
string fs1 = fs + " ";
string fs2 = fs + Environment.NewLine;
for (int i = 0; i < a.Length; i++)
Console.Write(((i < a.Length - 1) ? fs1 : fs2), a[i]);
});
}
public static void WriteLines<T>(T[] a) {
wwp(() => {
string fs = wfm(typeof(T)) + Environment.NewLine;
foreach (T x in a)
Console.Write(fs, x);
});
}
}
#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, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 230, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 230, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 57, 64, 196, 0, 210, 8, 196, 0, 46]]
| 8
| 4,213
| 24
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
// using Debug;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
Solve();
// WriteLine(Solve());
}
static void Solve() {
var nm = Input.ar;
var res = 1L;
var dic = Calculation.Factorize(nm[1]);
var com = new Modulo.Combination(dic.Values.Max() + nm[0]);
foreach (var val in dic.Values) {
res *= com.Comb(val + nm[0] - 1, val);
res %= Input.MOD;
}
WriteLine(res);
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static char[][] gred(int h) =>
Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
public static int[][] ar2D(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] arL2D(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const long Inf = (long)1e18;
public const double eps = 1e-6;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Calculation {
public static int LCM(int num1, int num2) {
return num1 / GCD(num1, num2) * num2;
}
public static long LCM(long num1, long num2) {
return num1 / GCD(num1, num2) * num2;
}
public static int GCD(int num1, int num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static long GCD(long num1, long num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static List<int> GetPrime(long num) {
if (num < 2)
return new List<int>();
var prime = new List<int> { 2 };
var bo = new bool[num + 1];
for (var i = 3; i <= num; i += 2)
if (!bo[i]) {
prime.Add(i);
for (var j = 3 * i; j <= num; j += 2 * i)
bo[j] = true;
}
return prime;
}
public static Dictionary<long, int> Factorize(long num) {
var dic = new Dictionary<long, int>();
for (var i = 2; i * i <= num; i++) {
var ct = 0;
while (num % i == 0) {
ct++;
num /= i;
}
if (ct != 0)
dic[i] = ct;
}
if (num != 1)
dic[num] = 1;
return dic;
}
}
public class Modulo {
private static int Multiple(int num1, int num2) => (int)(BigMul(num1, num2) %
Input.MOD);
public static int Pow(int m, int n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Pow(Multiple(m, m), n / 2);
else
return Multiple(Pow(Multiple(m, m), n / 2), m);
}
public static int Div(int a, int b) => Multiple(a, Pow(b, Input.MOD - 2));
public class Combination {
private int[] _fac;
public Combination(int num) //้ไนใใกใขๅ
{
_fac = new int[num + 1];
_fac[0] = 1;
for (var i = 1; i <= num; i++)
_fac[i] = Multiple(_fac[i - 1], i);
}
public int Comb(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
var calc = _fac[n];
calc = Div(calc, _fac[r]);
calc = Div(calc, _fac[n - r]);
return calc;
}
public int fac(int num) => _fac[num];
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
// using Debug;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
// Solve();
WriteLine(Solve());
}
static long Solve() {
var nm = Input.ar;
if (nm[1] == 1)
return 1;
var res = 1L;
var dic = Calculation.Factorize(nm[1]);
var com = new Modulo.Combination(dic.Values.Max() + nm[0]);
foreach (var val in dic.Values) {
res *= com.Comb(val + nm[0] - 1, val);
res %= Input.MOD;
}
return res;
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static char[][] gred(int h) =>
Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
public static int[][] ar2D(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] arL2D(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const long Inf = (long)1e18;
public const double eps = 1e-6;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Calculation {
public static int LCM(int num1, int num2) {
return num1 / GCD(num1, num2) * num2;
}
public static long LCM(long num1, long num2) {
return num1 / GCD(num1, num2) * num2;
}
public static int GCD(int num1, int num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static long GCD(long num1, long num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static List<int> GetPrime(long num) {
if (num < 2)
return new List<int>();
var prime = new List<int> { 2 };
var bo = new bool[num + 1];
for (var i = 3; i <= num; i += 2)
if (!bo[i]) {
prime.Add(i);
for (var j = 3 * i; j <= num; j += 2 * i)
bo[j] = true;
}
return prime;
}
public static Dictionary<long, int> Factorize(long num) {
var dic = new Dictionary<long, int>();
for (var i = 2; i * i <= num; i++) {
var ct = 0;
while (num % i == 0) {
ct++;
num /= i;
}
if (ct != 0)
dic[i] = ct;
}
if (num != 1)
dic[num] = 1;
return dic;
}
}
public class Modulo {
private static int Multiple(int num1, int num2) => (int)(BigMul(num1, num2) %
Input.MOD);
public static int Pow(int m, int n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Pow(Multiple(m, m), n / 2);
else
return Multiple(Pow(Multiple(m, m), n / 2), m);
}
public static int Div(int a, int b) => Multiple(a, Pow(b, Input.MOD - 2));
public class Combination {
private int[] _fac;
public Combination(int num) //้ไนใใกใขๅ
{
_fac = new int[num + 1];
_fac[0] = 1;
for (var i = 1; i <= num; i++)
_fac[i] = Multiple(_fac[i - 1], i);
}
public int Comb(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
var calc = _fac[n];
calc = Div(calc, _fac[r]);
calc = Div(calc, _fac[n - r]);
return calc;
}
public int fac(int num) => _fac[num];
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35], ["-", 0, 195, 8, 196, 0, 1, 0, 213, 63, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 8, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25]]
| 8
| 1,014
| 21
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var nm = Input.ar;
var dic = Calculation.Factorize(nm[1]);
var com = new Modulo.Combination(nm[0] + dic.Values.Max());
var res = 1L;
foreach (var val in dic.Values)
res = (res * com.Comb(nm[0] + val - 1, val)) % Input.MOD;
WriteLine(res);
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static int[][] twodim(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] twodimL(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const double eps = 1e-11;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Calculation {
public static int LCM(int num1, int num2) {
return num1 / GCD(num1, num2) * num2;
}
public static long LCM(long num1, long num2) {
return num1 / GCD(num1, num2) * num2;
}
public static int GCD(int num1, int num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static long GCD(long num1, long num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static List<int> GetPrime(long num) {
if (num < 2)
return new List<int>();
var prime = new List<int> { 2 };
var bo = new bool[num + 1];
for (var i = 3; i <= num; i += 2)
if (!bo[i]) {
prime.Add(i);
for (var j = 3 * i; j <= num; j += 2 * i)
bo[j] = true;
}
return prime;
}
public static Dictionary<long, int> Factorize(long num) {
var dic = new Dictionary<long, int>();
for (var i = 2; i * i <= num; i++) {
var ct = 0;
while (num % i == 0) {
ct++;
num /= i;
}
if (ct != 0)
dic[i] = ct;
}
if (num != 1)
dic[num] = 1;
return dic;
}
}
public class Modulo {
private static int Multiple(int num1, int num2) => (int)(BigMul(num1, num2) %
Input.MOD);
public static int Pow(int m, int n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Pow(Multiple(m, m), n / 2);
else
return Multiple(Pow(Multiple(m, m), n / 2), m);
}
public static int Div(int a, int b) => Multiple(a, Pow(b, Input.MOD - 2));
public class Combination {
private int[] _fac;
public Combination(int num) //้ไนใใกใขๅ
{
_fac = new int[num + 1];
_fac[0] = 1;
for (var i = 1; i <= num; i++)
_fac[i] = Multiple(_fac[i - 1], i);
}
public int Comb(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
var calc = _fac[n];
calc = Div(calc, _fac[r]);
calc = Div(calc, _fac[n - r]);
return calc;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
class Program {
static void Main(string[] args) {
var nm = Input.ar;
if (nm[1] == 1) {
WriteLine(1);
return;
}
var dic = Calculation.Factorize(nm[1]);
var com = new Modulo.Combination(nm[0] + dic.Values.Max());
var res = 1L;
foreach (var val in dic.Values)
res = (res * com.Comb(nm[0] + val - 1, val)) % Input.MOD;
WriteLine(res);
}
}
public class Input {
public static string read => ReadLine();
public static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
public static int num => ToInt32(read);
public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
public static long numL => ToInt64(read);
public static int[][] twodim(int num) =>
Enumerable.Repeat(0, num).Select(v => ar).ToArray();
public static long[][] twodimL(int num) =>
Enumerable.Repeat(0, num).Select(v => arL).ToArray();
public const double eps = 1e-11;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Calculation {
public static int LCM(int num1, int num2) {
return num1 / GCD(num1, num2) * num2;
}
public static long LCM(long num1, long num2) {
return num1 / GCD(num1, num2) * num2;
}
public static int GCD(int num1, int num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static long GCD(long num1, long num2) {
return num1<num2 ? GCD(num2, num1) : num2> 0 ? GCD(num2, num1 % num2)
: num1;
}
public static List<int> GetPrime(long num) {
if (num < 2)
return new List<int>();
var prime = new List<int> { 2 };
var bo = new bool[num + 1];
for (var i = 3; i <= num; i += 2)
if (!bo[i]) {
prime.Add(i);
for (var j = 3 * i; j <= num; j += 2 * i)
bo[j] = true;
}
return prime;
}
public static Dictionary<long, int> Factorize(long num) {
var dic = new Dictionary<long, int>();
for (var i = 2; i * i <= num; i++) {
var ct = 0;
while (num % i == 0) {
ct++;
num /= i;
}
if (ct != 0)
dic[i] = ct;
}
if (num != 1)
dic[num] = 1;
return dic;
}
}
public class Modulo {
private static int Multiple(int num1, int num2) => (int)(BigMul(num1, num2) %
Input.MOD);
public static int Pow(int m, int n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return Pow(Multiple(m, m), n / 2);
else
return Multiple(Pow(Multiple(m, m), n / 2), m);
}
public static int Div(int a, int b) => Multiple(a, Pow(b, Input.MOD - 2));
public class Combination {
private int[] _fac;
public Combination(int num) //้ไนใใกใขๅ
{
_fac = new int[num + 1];
_fac[0] = 1;
for (var i = 1; i <= num; i++)
_fac[i] = Multiple(_fac[i - 1], i);
}
public int Comb(int n, int r) {
if (n < r)
return 0;
if (n == r)
return 1;
var calc = _fac[n];
calc = Div(calc, _fac[r]);
calc = Div(calc, _fac[n - r]);
return calc;
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 204, 205, 22], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 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
| 915
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
const long MOD = 1000000007;
// O(โN)
// Nใฎ็ด ๅ ๆฐใใชในใใง่ฟใ
static List<int> Prime(int N) {
List<int> p = new List<int>();
for (int i = 2; i <= Math.Sqrt(N); i++) {
while (N % i == 0) {
p.Add(i);
N /= i;
}
}
if (N != 1)
p.Add(N);
return p;
}
//ใณใณใใใผใทใงใณใฎ่จ็ฎ
//(N)C(K)ใ่จ็ฎ
static long Conb(int N, int K) {
long[,] c = new long[N + 1, K + 1];
for (int i = 0; i <= N; i++) {
c[i, 0] = 1;
if (i <= K)
c[i, i] = 1;
}
for (int n = 1; n <= N; n++) {
for (int k = 1; k <= K; k++) {
c[n, k] = c[n - 1, k] + c[n - 1, k - 1];
c[n, k] %= MOD; // 64bitใ่ถ
ใใชใใใใซ1000000007ใงๅฒใ
}
}
return c[N, K];
}
static void Solve(int N, int M) {
//็ด ๅ ๆฐใฎใชในใ(prime_list)
List<int> prime_list = Prime(M);
// Console.WriteLine("prime_list:" + string.Join(" ", prime_list));
// prime_listๅ
ใฎๅ็ด ๅ ๆฐใฎๆๆฐใ่จ็ฎ(exp)
List<int> exp = new List<int>();
int cur = prime_list[0];
//็ด ๅ ๆฐcurใฎๆฐ(ๆๆฐ)ใใซใฆใณใ
int cnt = 0;
foreach (int val in prime_list) {
if (cur == val) {
cnt++;
} else {
exp.Add(cnt);
cnt = 1;
cur = val;
}
}
exp.Add(cnt);
// Console.WriteLine("exp:" + string.Join(" ", exp));
//็ญใans
//(exp[i] + N - 1)C(exp[i])ใๅexp[i]ใซใคใใฆ่กใ
long ans = 1;
for (int i = 0; i < exp.Count; i++) {
ans = (ans * Conb(exp[i] + N - 1, exp[i])) % MOD;
}
Console.WriteLine(ans);
}
static void Main(string[] args) {
//ๅ
ฅๅ1(S)
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
Solve(N, M);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace CSharpSample01 {
class Program {
const long MOD = 1000000007;
// O(โN)
// Nใฎ็ด ๅ ๆฐใใชในใใง่ฟใ
static List<int> Prime(int N) {
List<int> p = new List<int>();
for (int i = 2; i <= Math.Sqrt(N); i++) {
while (N % i == 0) {
p.Add(i);
N /= i;
}
}
if (N != 1)
p.Add(N);
return p;
}
//ใณใณใใใผใทใงใณใฎ่จ็ฎ
//(N)C(K)ใ่จ็ฎ
static long Conb(int N, int K) {
long[,] c = new long[N + 1, K + 1];
for (int i = 0; i <= N; i++) {
c[i, 0] = 1;
if (i <= K)
c[i, i] = 1;
}
for (int n = 1; n <= N; n++) {
for (int k = 1; k <= K; k++) {
c[n, k] = c[n - 1, k] + c[n - 1, k - 1];
c[n, k] %= MOD; // 64bitใ่ถ
ใใชใใใใซ1000000007ใงๅฒใ
}
}
return c[N, K];
}
static void Solve(int N, int M) {
//็ด ๅ ๆฐใฎใชในใ(prime_list)
List<int> prime_list = Prime(M);
// M = 1ใฎๆใ1ใฏ็ด ๆฐใงใฏใชใใฎใงprime_listใซ่ฆ็ด (็ด ๆฐ)ใฏใชใ
// 1 * ... * 1 = M ใจ Nๅ 1ใๆใใ1้ใ
if (prime_list.Count == 0) {
Console.WriteLine("1");
return;
}
// Console.WriteLine("prime_list:" + string.Join(" ", prime_list));
// prime_listๅ
ใฎๅ็ด ๅ ๆฐใฎๆๆฐใ่จ็ฎ(exp)
List<int> exp = new List<int>();
int cur = prime_list[0];
//็ด ๅ ๆฐcurใฎๆฐ(ๆๆฐ)ใใซใฆใณใ
int cnt = 0;
foreach (int val in prime_list) {
if (cur == val) {
cnt++;
} else {
exp.Add(cnt);
cnt = 1;
cur = val;
}
}
exp.Add(cnt);
// Console.WriteLine("exp:" + string.Join(" ", exp));
//็ญใans
//(exp[i] + N - 1)C(exp[i])ใๅexp[i]ใซใคใใฆ่กใ
long ans = 1;
for (int i = 0; i < exp.Count; i++) {
ans = (ans * Conb(exp[i] + N - 1, exp[i])) % MOD;
}
Console.WriteLine(ans);
}
static void Main(string[] args) {
//ๅ
ฅๅ1(S)
string[] input = Console.ReadLine().Split(' ');
int N = int.Parse(input[0]);
int M = int.Parse(input[1]);
Solve(N, M);
}
}
}
|
[["+", 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], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 64, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 484
| 21
|
using System;
using System.Linq; //ใชในใใฎไฝฟ็จ
using System.Collections.Generic;
using System.Text; //ใใญในใใฎ้ซ้ๅบๅใซๅฟ
่ฆ
class Program {
static bool[] isPrimes = makePrimeList(100000); // i-1ใ็ด ๆฐใใฉใใ
static string[] input = Console.ReadLine().Split(' ');
static long n = long.Parse(input[0]);
static long m = long.Parse(input[1]);
static long p = 1000000007;
static long[] factorials = new long[2 * n + 1]; // i!(mod p)ใๅ
ใซใกใข
static long[] factorialRs = new long[2 * n + 1]; // i!^-1(mod p), pใฏ็ด ๆฐ
static void Main() {
long answer = 1;
factorials[0] = 1;
factorialRs[2 * n] = DivideModFactorial(2 * n, p);
for (long i = 1; i <= 2 * n; i++) {
factorials[i] = (factorials[i - 1] * i) % p; // i!(mod p)
factorialRs[2 * n - i] =
(factorialRs[2 * n + 1 - i] * (2 * n + 1 - i)) % p; //้ๅ
ใๅ
ใซใกใข
}
makePrimeList(100000);
List<long> factorList = Factoring(m);
int countMemo = 0;
for (int i = 0; i < factorList.Count(); i++) {
// Console.WriteLine(i+" "+factorList[i]);
if (i == 0)
countMemo++;
else if (factorList[i] == factorList[i - 1])
countMemo++;
else {
answer *= factorials[countMemo + (n - 1)];
answer %= p;
answer *= factorialRs[countMemo];
answer %= p;
answer *= factorialRs[n - 1];
answer %= p;
countMemo = 1;
}
}
if (countMemo > 0) {
answer *= factorials[countMemo + (n - 1)];
answer %= p;
answer *= factorialRs[countMemo];
answer %= p;
answer *= factorialRs[n - 1];
answer %= p;
}
Console.WriteLine(answer);
}
static List<long> Factoring(
long
originalNum) { // makePrimeListใซใใisPrimesใ็จใใฆใๅผๆฐใO(โn)ใง็ด ๅ ๆฐๅ่งฃใใชในใใซใฏๅใๆฐใๅซใใ
//ไพใใฐ1ใฏ{},12ใฏ{2,2,3},17ใฏ{17}ใ่ฟใใ
List<long> answers = new List<long>();
for (long i = 2; i <= Math.Sqrt(originalNum); i++) {
if (!isPrimes[i - 1])
continue; //็ด ๆฐใงใชใใจใ
else {
while (originalNum % i == 0) {
originalNum /= i;
answers.Add(i);
}
}
}
if (originalNum != 1)
answers.Add(originalNum);
return answers;
}
static bool[] makePrimeList(
long
maxPrime) { //ใๅผๆฐ1ไปฅไธใmaxไปฅไธใฎ็ด ๆฐๅคๅฎใใใจใฉใในใใในใฎ็ฏฉใ็จใใฆO(n)ใ
bool[] isPrimes = new bool[maxPrime]; //็ด ๆฐใชในใ
isPrimes[0] = false; // 1ใฏ็ด ๆฐใงใชใใฎใงfalse
for (long i = 1; i < maxPrime; i++)
isPrimes[i] = true; //็ด ๆฐใจไปฎๅฎใใฆtrue
for (long i = 2; i <= Math.Sqrt(maxPrime); i++) {
if (isPrimes[i - 1]) {
for (long j = i * 2; j <= maxPrime; j += i) {
isPrimes[j - 1] = false; //็ด ๆฐใงใชใใฎใงfalse
}
}
}
return isPrimes;
}
static long MathPow(long x, long a) //ๆปใๅคใฏx^aใO(loga)
{
long num = 2;
long answer = 1;
long check = a;
long memo = x;
while (check > 0) {
if (check % num == num / 2) {
check -= num / 2;
answer *= memo;
}
memo *= memo;
num *= 2;
}
return answer;
}
static long DivideMod(long x, long a, long p) //ๆปใๅคใฏx^a(mod p)ใO(loga)
{
long num = 2;
long answer = 1;
long check = a;
long memo = x % p;
while (check > 0) {
if (check % num == num / 2) {
check -= num / 2;
answer *= memo;
answer %= p;
}
memo *= memo;
memo %= p;
num *= 2;
}
return answer;
}
static long DivideModReverse(long x,
long p) //ๆปใๅคใฏx^-1(mod p), pใฏ็ด ๆฐใO(logp)
{
long answer = DivideMod(x, p - 2, p);
return answer;
}
static long ModFactorial(long x, long p) //ๆปใๅคใฏx!(mod p)
{
long answer = 1;
for (int i = 2; i <= x; i++) {
answer *= i;
answer %= p;
}
return answer;
}
static long DivideModFactorial(long x, long p) //ๆปใๅคใฏx!^-1(mod p), pใฏ็ด ๆฐ
{
long answer = 1;
for (long i = x; i >= 2; i--) {
answer *= DivideModReverse(i, p);
answer %= p;
}
return answer;
}
static long Comb(long a, long b, long p) //ๆปใๅคใฏ็ตใฟๅใใC(a,b)ใฎmod p
{
if (a - b < 0)
return 0; //ๅผๆฐa-bใ่ฒ ใชใ0ใ่ฟใ
long answer = 1;
answer *= factorials[a];
answer %= p;
answer *= factorialRs[a - b];
answer %= p;
answer *= factorialRs[b];
answer %= p;
return answer;
}
}
|
using System;
using System.Linq; //ใชในใใฎไฝฟ็จ
using System.Collections.Generic;
using System.Text; //ใใญในใใฎ้ซ้ๅบๅใซๅฟ
่ฆ
class Program {
static bool[] isPrimes = makePrimeList(100000); // i-1ใ็ด ๆฐใใฉใใ
static string[] input = Console.ReadLine().Split(' ');
static long n = long.Parse(input[0]);
static long m = long.Parse(input[1]);
static long p = 1000000007;
static long[] factorials = new long[200001]; // i!(mod p)ใๅ
ใซใกใข
static long[] factorialRs = new long[200001]; // i!^-1(mod p), pใฏ็ด ๆฐ
static void Main() {
long answer = 1;
factorials[0] = 1;
factorialRs[200000] = DivideModFactorial(200000, p);
for (long i = 1; i <= 200000; i++) {
factorials[i] = (factorials[i - 1] * i) % p; // i!(mod p)
factorialRs[200000 - i] =
(factorialRs[200001 - i] * (200001 - i)) % p; //้ๅ
ใๅ
ใซใกใข
}
makePrimeList(100000);
List<long> factorList = Factoring(m);
int countMemo = 0;
for (int i = 0; i < factorList.Count(); i++) {
// Console.WriteLine(i+" "+factorList[i]);
if (i == 0)
countMemo++;
else if (factorList[i] == factorList[i - 1])
countMemo++;
else {
answer *= factorials[countMemo + (n - 1)];
answer %= p;
answer *= factorialRs[countMemo];
answer %= p;
answer *= factorialRs[n - 1];
answer %= p;
countMemo = 1;
}
}
if (countMemo > 0) {
answer *= factorials[countMemo + (n - 1)];
answer %= p;
answer *= factorialRs[countMemo];
answer %= p;
answer *= factorialRs[n - 1];
answer %= p;
}
Console.WriteLine(answer);
}
static List<long> Factoring(
long
originalNum) { // makePrimeListใซใใisPrimesใ็จใใฆใๅผๆฐใO(โn)ใง็ด ๅ ๆฐๅ่งฃใใชในใใซใฏๅใๆฐใๅซใใ
//ไพใใฐ1ใฏ{},12ใฏ{2,2,3},17ใฏ{17}ใ่ฟใใ
List<long> answers = new List<long>();
for (long i = 2; i <= Math.Sqrt(originalNum); i++) {
if (!isPrimes[i - 1])
continue; //็ด ๆฐใงใชใใจใ
else {
while (originalNum % i == 0) {
originalNum /= i;
answers.Add(i);
}
}
}
if (originalNum != 1)
answers.Add(originalNum);
return answers;
}
static bool[] makePrimeList(
long
maxPrime) { //ใๅผๆฐ1ไปฅไธใmaxไปฅไธใฎ็ด ๆฐๅคๅฎใใใจใฉใในใใในใฎ็ฏฉใ็จใใฆO(n)ใ
bool[] isPrimes = new bool[maxPrime]; //็ด ๆฐใชในใ
isPrimes[0] = false; // 1ใฏ็ด ๆฐใงใชใใฎใงfalse
for (long i = 1; i < maxPrime; i++)
isPrimes[i] = true; //็ด ๆฐใจไปฎๅฎใใฆtrue
for (long i = 2; i <= Math.Sqrt(maxPrime); i++) {
if (isPrimes[i - 1]) {
for (long j = i * 2; j <= maxPrime; j += i) {
isPrimes[j - 1] = false; //็ด ๆฐใงใชใใฎใงfalse
}
}
}
return isPrimes;
}
static long MathPow(long x, long a) //ๆปใๅคใฏx^aใO(loga)
{
long num = 2;
long answer = 1;
long check = a;
long memo = x;
while (check > 0) {
if (check % num == num / 2) {
check -= num / 2;
answer *= memo;
}
memo *= memo;
num *= 2;
}
return answer;
}
static long DivideMod(long x, long a, long p) //ๆปใๅคใฏx^a(mod p)ใO(loga)
{
long num = 2;
long answer = 1;
long check = a;
long memo = x % p;
while (check > 0) {
if (check % num == num / 2) {
check -= num / 2;
answer *= memo;
answer %= p;
}
memo *= memo;
memo %= p;
num *= 2;
}
return answer;
}
static long DivideModReverse(long x,
long p) //ๆปใๅคใฏx^-1(mod p), pใฏ็ด ๆฐใO(logp)
{
long answer = DivideMod(x, p - 2, p);
return answer;
}
static long ModFactorial(long x, long p) //ๆปใๅคใฏx!(mod p)
{
long answer = 1;
for (int i = 2; i <= x; i++) {
answer *= i;
answer %= p;
}
return answer;
}
static long DivideModFactorial(long x, long p) //ๆปใๅคใฏx!^-1(mod p), pใฏ็ด ๆฐ
{
long answer = 1;
for (long i = x; i >= 2; i--) {
answer *= DivideModReverse(i, p);
answer %= p;
}
return answer;
}
static long Comb(long a, long b, long p) //ๆปใๅคใฏ็ตใฟๅใใC(a,b)ใฎmod p
{
if (a - b < 0)
return 0; //ๅผๆฐa-bใ่ฒ ใชใ0ใ่ฟใ
long answer = 1;
answer *= factorials[a];
answer %= p;
answer *= factorialRs[a - b];
answer %= p;
answer *= factorialRs[b];
answer %= p;
return answer;
}
}
|
[["-", 39, 224, 225, 226, 0, 16, 31, 16, 31, 203], ["-", 39, 224, 225, 226, 0, 16, 31, 16, 17, 48], ["-", 39, 224, 225, 226, 0, 16, 31, 16, 12, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 31, 203], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 17, 48], ["-", 31, 204, 206, 207, 0, 28, 0, 16, 12, 22], ["+", 0, 11, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 31, 203], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 203], ["-", 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, 15, 16, 12, 203], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 31, 203], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 17, 48], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 31, 204, 206, 207, 0, 28, 0, 16, 31, 203], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 31, 203], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 17, 48], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 17, 72], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 12, 203], ["-", 12, 23, 0, 16, 31, 16, 31, 16, 31, 203], ["-", 12, 23, 0, 16, 31, 16, 31, 16, 17, 48], ["-", 12, 23, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 17, 72], ["-", 0, 16, 12, 23, 0, 16, 31, 16, 12, 203], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 31, 203]]
| 8
| 982
| 40
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace kp {
public class Program {
// static long[,] cmb;
static int MAX_INT = 1000000007;
static void Main(string[] args) {
// long N = long.Parse(Console.ReadLine());
int[] input =
Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
int N = input[0];
int M = input[1];
// Mใ็ด ๅ ๆฐๅ่งฃใใ
Dictionary<int, int> factor = new Dictionary<int, int>();
int sum = 0;
for (int i = 2; i <= M / 2 + 1; i++) {
while (M % i == 0) {
if (factor.ContainsKey(i)) {
factor[i] += 1;
sum++;
} else {
factor.Add(i, 1);
sum++;
}
M /= i;
}
if (M == 1)
break;
}
if (M > 1) {
factor.Add(M, 1);
sum++;
}
long[,] cmb = new long[sum + N, sum + 1];
// iCjใฎ่กจใไฝใ
cmb[0, 0] = 1;
cmb[1, 0] = 1;
cmb[1, 1] = 1;
for (int i = 2; i <= sum + N - 1; i++) {
for (int j = 0; j <= i && j <= sum; j++) {
if (j > 0) {
long a = (cmb[i - 1, j - 1] + cmb[i - 1, j]) % MAX_INT;
cmb[i, j] = a;
} else {
long a = (cmb[i - 1, j]) % MAX_INT;
cmb[i, j] = a;
}
}
}
long ret = 1;
// N-1ๅใฎไปๅใใจใf^?ใฎ?ๅใฎไธฆใณๆฟใใๆใๅใใใ
foreach (var f in factor.Keys) {
int num = factor[f];
// sumCnumใๆใใฆใใ
long a = cmb[(num + N - 1), num];
ret = (ret * a) % MAX_INT;
}
Console.WriteLine(ret + "");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace kp {
public class Program {
// static long[,] cmb;
static int MAX_INT = 1000000007;
static void Main(string[] args) {
// long N = long.Parse(Console.ReadLine());
int[] input =
Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
int N = input[0];
int M = input[1];
// Mใ็ด ๅ ๆฐๅ่งฃใใ
Dictionary<int, int> factor = new Dictionary<int, int>();
int sum = 1;
factor.Add(1, 0);
for (int i = 2; i <= M / 2 + 1; i++) {
while (M % i == 0) {
if (factor.ContainsKey(i)) {
factor[i] += 1;
sum++;
} else {
factor.Add(i, 1);
sum++;
}
M /= i;
}
if (M == 1)
break;
}
if (M > 1) {
factor.Add(M, 1);
sum++;
}
long[,] cmb = new long[sum + N, sum + 1];
// iCjใฎ่กจใไฝใ
cmb[0, 0] = 1;
cmb[1, 0] = 1;
cmb[1, 1] = 1;
for (int i = 2; i <= sum + N - 1; i++) {
for (int j = 0; j <= i && j <= sum; j++) {
if (j > 0) {
long a = (cmb[i - 1, j - 1] + cmb[i - 1, j]) % MAX_INT;
cmb[i, j] = a;
} else {
long a = (cmb[i - 1, j]) % MAX_INT;
cmb[i, j] = a;
}
}
}
long ret = 1;
// N-1ๅใฎไปๅใใจใf^?ใฎ?ๅใฎไธฆใณๆฟใใๆใๅใใใ
foreach (var f in factor.Keys) {
int num = factor[f];
// sumCnumใๆใใฆใใ
long a = cmb[(num + N - 1), num];
ret = (ret * a) % MAX_INT;
}
Console.WriteLine(ret + "");
}
}
}
|
[["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25]]
| 8
| 449
| 9
|
using System;
using System.Collections.Generic;
namespace ABC110_D___Factorization {
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 primeFactors = new List<int>();
var factor = 2;
long MOD = 1000000007;
while (M > 1) {
if (factor > Math.Sqrt(M)) {
primeFactors.Add(M);
break;
}
while (M % factor == 0) {
M /= factor;
primeFactors.Add(factor);
}
factor += 1;
}
var primeCounts = new List<int>();
primeCounts.Add(1);
for (int i = 1; i < primeFactors.Count; i++)
if (primeFactors[i] == primeFactors[i - 1])
primeCounts[primeCounts.Count - 1] += 1;
else
primeCounts.Add(1);
Combination.combInit(1000000, MOD);
long result = 1;
foreach (int i in primeCounts) {
result *= Combination.combination(N + i - 1, i);
result %= MOD;
}
Console.WriteLine(result);
}
}
static class Combination {
static long combMax;
static long combMOD;
static long[] factorial;
static long[] inverse;
static long[] factInv;
public static void combInit(long _max, long _mod) {
combMax = _max;
combMOD = _mod;
factorial = new long[combMax];
inverse = new long[combMax];
factInv = new long[combMax];
factorial[0] = factorial[1] = 1;
factInv[0] = factInv[1] = 1;
inverse[1] = 1;
for (int i = 2; i < combMax; i++) {
factorial[i] = factorial[i - 1] * i % combMOD;
inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
}
}
public static long combination(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
}
}
}
|
using System;
using System.Collections.Generic;
namespace ABC110_D___Factorization {
class Program {
static void Main(string[] args) { Console.WriteLine(solver()); }
static long solver() {
var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = NM[0];
var M = NM[1];
if (M == 1)
return 1;
var primeFactors = new List<int>();
var factor = 2;
long MOD = 1000000007;
while (M > 1) {
if (factor > Math.Sqrt(M)) {
primeFactors.Add(M);
break;
}
while (M % factor == 0) {
M /= factor;
primeFactors.Add(factor);
}
factor += 1;
}
var primeCounts = new List<int>();
primeCounts.Add(1);
for (int i = 1; i < primeFactors.Count; i++)
if (primeFactors[i] == primeFactors[i - 1])
primeCounts[primeCounts.Count - 1] += 1;
else
primeCounts.Add(1);
Combination.combInit(1000000, MOD);
long result = 1;
foreach (int i in primeCounts) {
result *= Combination.combination(N + i - 1, i);
result %= MOD;
}
return result;
}
}
static class Combination {
static long combMax;
static long combMOD;
static long[] factorial;
static long[] inverse;
static long[] factInv;
public static void combInit(long _max, long _mod) {
combMax = _max;
combMOD = _mod;
factorial = new long[combMax];
inverse = new long[combMax];
factInv = new long[combMax];
factorial[0] = factorial[1] = 1;
factInv[0] = factInv[1] = 1;
inverse[1] = 1;
for (int i = 2; i < combMax; i++) {
factorial[i] = factorial[i - 1] * i % combMOD;
inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
}
}
public static long combination(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
}
}
}
|
[["+", 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, 213, 63, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 24], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 46], ["+", 0, 235, 8, 201, 0, 195, 0, 251, 0, 115], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 24], ["+", 0, 235, 8, 201, 0, 195, 54, 55, 0, 25], ["+", 0, 235, 8, 201, 0, 195, 8, 196, 0, 45], ["+", 8, 201, 0, 195, 8, 196, 0, 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, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 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, 201, 0, 195, 8, 196, 0, 37, 0, 38], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25]]
| 8
| 501
| 31
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace ABC110 {
class Program {
static long mod = 1000000007;
static Dictionary<long, int> Factorize(long M) {
long Mcopy = M;
Dictionary<long, int> res = new Dictionary<long, int>();
for (int i = 2; i < Mcopy; i++) {
while (M % i == 0) {
if (!res.ContainsKey(i)) {
res[i] = 1;
} else {
res[i]++;
}
M /= i;
}
}
return res;
}
static long Modpow(long a, long n) {
long res = 1;
while (n > 0) {
if ((n & 1) == 1) {
res = (res * a) % mod;
}
a = (a * a) % mod;
n = n >> 1;
}
return res;
}
static long Modinv(long a) { return Modpow(a, mod - 2); }
static long Combination(long a, long b) {
long top = 1, bottom = 1;
for (long i = 1; i <= b; i++) {
top *= a - i + 1;
bottom *= i;
top = top % mod;
bottom = bottom % mod;
}
return (top * Modinv(bottom)) % mod;
}
public static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int N = int.Parse(s[0]);
long M = long.Parse(s[1]);
Dictionary<long, int> d = Factorize(M);
long res = 1;
foreach (long a in d.Keys) {
res *= Combination(d[a] + N - 1, d[a]);
res = res % mod;
}
Console.WriteLine(res);
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace ABC110 {
class Program {
static long mod = 1000000007;
static Dictionary<long, int> Factorize(long M) {
Dictionary<long, int> res = new Dictionary<long, int>();
long i = 2;
while (M != 1) {
while (M % i == 0) {
if (!res.ContainsKey(i)) {
res[i] = 1;
} else {
res[i]++;
}
M /= i;
}
i++;
}
return res;
}
static long Modpow(long a, long n) {
long res = 1;
while (n > 0) {
if ((n & 1) == 1) {
res = (res * a) % mod;
}
a = (a * a) % mod;
n = n >> 1;
}
return res;
}
static long Modinv(long a) { return Modpow(a, mod - 2); }
static long Combination(long a, long b) {
long top = 1, bottom = 1;
for (long i = 1; i <= b; i++) {
top *= a - i + 1;
bottom *= i;
top = top % mod;
bottom = bottom % mod;
}
return (top * Modinv(bottom)) % mod;
}
public static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int N = int.Parse(s[0]);
long M = long.Parse(s[1]);
Dictionary<long, int> d = Factorize(M);
long res = 1;
foreach (long a in d.Keys) {
res *= Combination(d[a] + N - 1, d[a]);
res = res % mod;
}
Console.WriteLine(res);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 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], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 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], ["-", 8, 201, 0, 195, 8, 196, 0, 7, 0, 35], ["-", 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, 52, 0, 89], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 24], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 79], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 223, 0, 29], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35]]
| 8
| 407
| 23
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program {
static long Mod = 1000000007;
static Dictionary<int, int> Factorize(int M) {
Dictionary<int, int> r = new Dictionary<int, int>();
while (M % 2 == 0) {
M = (M - (M % 2)) / 2;
if (r.ContainsKey(2))
r[2]++;
else
r.Add(2, 1);
}
for (int i = 3; i <= M; i += 2) {
while (M % i == 0) {
M = (M - (M % i)) / i;
if (r.ContainsKey(i))
r[i]++;
else
r.Add(i, 1);
}
}
return r;
}
public static void Main() {
string[] s = Console.ReadLine().Split(' ');
int N = int.Parse(s[0]);
int M = int.Parse(s[1]);
var r = Factorize(M);
int maxduality = r.Max(x => x.Value);
long[][] dp = new long [maxduality + 1][];
for (int i = 0; i <= maxduality; i++)
dp[i] = new long[N + 1];
for (int i = 0; i <= N; i++) {
dp[1][i] = i;
dp[0][i] = i;
}
for (int i = 0; i <= maxduality; i++) {
dp[i][1] = 1;
dp[i][0] = 1;
}
for (int i = 2; i <= maxduality; i++) {
for (int j = 2; j <= N; j++) {
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % Mod;
}
}
long q = 1;
foreach (var i in r) {
q = (q * dp[i.Value][N]) % Mod;
}
Console.WriteLine(q);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program {
static long Mod = 1000000007;
static Dictionary<int, int> Factorize(int M) {
Dictionary<int, int> r = new Dictionary<int, int>();
while (M % 2 == 0) {
M = (M - (M % 2)) / 2;
if (r.ContainsKey(2))
r[2]++;
else
r.Add(2, 1);
}
for (int i = 3; i <= M; i += 2) {
while (M % i == 0) {
M = (M - (M % i)) / i;
if (r.ContainsKey(i))
r[i]++;
else
r.Add(i, 1);
}
}
return r;
}
public static void Main() {
string[] s = Console.ReadLine().Split(' ');
int N = int.Parse(s[0]);
int M = int.Parse(s[1]);
var r = Factorize(M);
int maxduality;
if (r.Count > 0)
maxduality = r.Max(x => x.Value);
else
maxduality = 1;
long[][] dp = new long [maxduality + 1][];
for (int i = 0; i <= maxduality; i++)
dp[i] = new long[N + 1];
for (int i = 0; i <= N; i++) {
dp[1][i] = i;
dp[0][i] = i;
}
for (int i = 0; i <= maxduality; i++) {
dp[i][1] = 1;
dp[i][0] = 1;
}
for (int i = 2; i <= maxduality; i++) {
for (int j = 2; j <= N; j++) {
dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % Mod;
}
}
long q = 1;
if (r.Count > 0)
foreach (var i in r)
q = (q * dp[i.Value][N]) % Mod;
Console.WriteLine(q);
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 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, 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, 11, 31, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 95], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 31, 22], ["+", 0, 57, 75, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 75, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 75, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46]]
| 8
| 473
| 25
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.ABC_110 {
class D {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
long m = long.Parse(input[1]);
long mask = 1000000000 + 7;
long[] primes = PrimeNumbers(1, (long)Math.Sqrt(m));
var primeCnts = new long[primes.Length];
long mSub = m;
for (int i = 0; i < primes.Length; i++) {
while (mSub % primes[i] == 0) {
mSub /= primes[i];
primeCnts[i]++;
}
// Console.WriteLine(primes[i] + " " + primeCnts[i]);
}
long res = 1;
for (int i = 0; i < primes.Length; i++) {
if (primeCnts[i] == 0)
continue;
res *= Combination(primeCnts[i] + n - 1, primeCnts[i], mask);
res %= mask;
}
Console.WriteLine(res);
}
static long Combination(long n, long m, long mask) {
if (n - m < m) {
m = n - m;
}
long val = Permutation(n, m, mask);
for (int i = 1; i <= m; i++) {
val = MultiMod(val, ReverseMod(i, mask - 2, mask), mask);
}
return val;
}
static long Permutation(long n, long m, long mask) {
long val = 1;
for (long i = 0; i < m; i++) {
val *= ((n - i) % mask);
val %= mask;
}
return val;
}
static long MultiMod(long a, long b, long mask) {
return ((a % mask) * (b % mask)) % mask;
}
static long ReverseMod(long a, long pow, long mask) {
if (pow == 0)
return 1;
else if (pow == 1)
return a % mask;
else {
long halfMod = ReverseMod(a, pow / 2, mask);
long nextMod = MultiMod(halfMod, halfMod, mask);
if (pow % 2 == 0) {
return nextMod;
} else {
return MultiMod(nextMod, a, mask);
}
}
}
static long[] PrimeNumbers(long min, long max) {
var primes = new List<long>();
if (min <= 2 && max >= 2) {
primes.Add(2);
}
for (long i = 3; i <= max; i += 2) {
long rootI = (long)Math.Sqrt(i);
bool isPrime = true;
for (long j = 3; j <= rootI; j += 2) {
if (i % j == 0) {
isPrime = false;
break;
} else {
continue;
}
}
if (isPrime) {
primes.Add(i);
}
}
return primes.ToArray();
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.ABC_110 {
class D {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]);
long m = long.Parse(input[1]);
long mask = 1000000000 + 7;
long[] primes = PrimeNumbers(1, (long)Math.Sqrt(m));
var primeCnts = new long[primes.Length];
long mSub = m;
for (int i = 0; i < primes.Length; i++) {
while (mSub % primes[i] == 0) {
mSub /= primes[i];
primeCnts[i]++;
}
// Console.WriteLine(primes[i] + " " + primeCnts[i]);
}
long res = 1;
for (int i = 0; i < primes.Length; i++) {
if (primeCnts[i] == 0)
continue;
res *= Combination(primeCnts[i] + n - 1, primeCnts[i], mask);
res %= mask;
}
if (mSub > 1) {
res *= n;
res %= mask;
}
Console.WriteLine(res);
}
static long Combination(long n, long m, long mask) {
if (n - m < m) {
m = n - m;
}
long val = Permutation(n, m, mask);
for (int i = 1; i <= m; i++) {
val = MultiMod(val, ReverseMod(i, mask - 2, mask), mask);
}
return val;
}
static long Permutation(long n, long m, long mask) {
long val = 1;
for (long i = 0; i < m; i++) {
val *= ((n - i) % mask);
val %= mask;
}
return val;
}
static long MultiMod(long a, long b, long mask) {
return ((a % mask) * (b % mask)) % mask;
}
static long ReverseMod(long a, long pow, long mask) {
if (pow == 0)
return 1;
else if (pow == 1)
return a % mask;
else {
long halfMod = ReverseMod(a, pow / 2, mask);
long nextMod = MultiMod(halfMod, halfMod, mask);
if (pow % 2 == 0) {
return nextMod;
} else {
return MultiMod(nextMod, a, mask);
}
}
}
static long[] PrimeNumbers(long min, long max) {
var primes = new List<long>();
if (min <= 2 && max >= 2) {
primes.Add(2);
}
for (long i = 3; i <= max; i += 2) {
long rootI = (long)Math.Sqrt(i);
bool isPrime = true;
for (long j = 3; j <= rootI; j += 2) {
if (i % j == 0) {
isPrime = false;
break;
} else {
continue;
}
}
if (isPrime) {
primes.Add(i);
}
}
return primes.ToArray();
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 108], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 806
| 16
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc110_d {
class Program {
const int mod = 1000000007;
static long Calc_pow(long x, long pow) {
if (pow == 0)
return 1;
long a = Calc_pow(x, pow / 2);
a = a * a % mod;
if (pow % 2 == 1)
a *= x;
return a % mod;
}
static long[] fact;
static void Init_fact(int n) {
fact = new long[n];
fact[0] = 1;
for (int i = 1; i < n; i++)
fact[i] = fact[i - 1] * i % mod;
}
static long Combination(long n, long r) {
return fact[n] * Calc_pow(fact[r] * fact[n - r] % mod, mod - 2) % mod;
}
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
List<int> primes = new List<int>();
double sq = Math.Sqrt(x[1]);
for (int i = 2; i < sq + 1; i++) {
int a = 0;
while (x[1] % i == 0) {
x[1] /= i;
a++;
}
if (a > 0)
primes.Add(a);
}
long ret = 1;
Init_fact(1000000);
foreach (var num in primes) {
ret *= Combination(x[0] + num - 1, num);
ret %= mod;
}
Console.WriteLine(ret);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace abc110_d {
class Program {
const int mod = 1000000007;
static long Calc_pow(long x, long pow) {
if (pow == 0)
return 1;
long a = Calc_pow(x, pow / 2);
a = a * a % mod;
if (pow % 2 == 1)
a *= x;
return a % mod;
}
static long[] fact;
static void Init_fact(int n) {
fact = new long[n];
fact[0] = 1;
for (int i = 1; i < n; i++)
fact[i] = fact[i - 1] * i % mod;
}
static long Combination(long n, long r) {
return fact[n] * Calc_pow(fact[r] * fact[n - r] % mod, mod - 2) % mod;
}
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
List<int> primes = new List<int>();
double sq = Math.Sqrt(x[1]);
for (int i = 2; i < sq + 1; i++) {
int a = 0;
while (x[1] % i == 0) {
x[1] /= i;
a++;
}
if (a > 0)
primes.Add(a);
}
if (x[1] > 1)
primes.Add(1);
long ret = 1;
Init_fact(1000000);
foreach (var num in primes) {
ret *= Combination(x[0] + num - 1, num);
ret %= mod;
}
Console.WriteLine(ret);
}
}
}
|
[["+", 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, 47], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 357
| 16
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC110.D {
class Program {
static void Main() {
var sc = new Scanner();
var n = sc.Nextint();
var m = sc.Nextint();
const int devisor = (int)1e9 + 7;
var mLeft = m;
var ans = 1L;
for (int i = 2; i * i < mLeft; i++) {
if (mLeft % i == 0) {
var cnt = 0;
while (mLeft % i == 0) {
cnt++;
mLeft /= i;
}
ans *= ModCombination(cnt + n - 1, n - 1, devisor);
ans %= devisor;
}
}
if (mLeft != 1) {
ans *= ModCombination(1 + n - 1, n - 1, devisor);
ans %= devisor;
}
Console.WriteLine(ans);
}
public static long ModCombination(long n, long r, int devisor) {
Console.Error.WriteLine(n + " " + r + " " + devisor);
if (r > n - r)
return ModCombination(n, n - r, devisor);
var molecule = 1L;
var denominator = 1L;
for (var i = 0L; i < r; i++) {
molecule *= n - i;
molecule %= devisor;
denominator *= i + 1;
denominator %= devisor;
}
return molecule * ModPow(denominator, devisor - 2, devisor) % devisor;
}
public static long ModPow(long value, int power, int devisor) {
if (power == 0)
return 1L;
if (power % 2 == 0) {
int halfPower = power / 2;
long halfResult = ModPow(value, halfPower, devisor);
return halfResult * halfResult % devisor;
} else {
return value * ModPow(value, power - 1, devisor) % devisor;
}
}
}
class Scanner {
string[] s;
long i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int Nextint() { return int.Parse(Next()); }
public int[] Arrayint(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Nextint() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (long i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(long N, double add = 0) {
double[] Array = new double[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
public decimal NextDecimal() { return decimal.Parse(Next()); }
public decimal[] ArrayDecimal(long N, decimal add = 0) {
decimal[] Array = new decimal[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDecimal();
}
return Array;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC110.D {
class Program {
static void Main() {
var sc = new Scanner();
var n = sc.Nextint();
var m = sc.Nextint();
const int devisor = (int)1e9 + 7;
var mLeft = m;
var ans = 1L;
for (int i = 2; i * i <= mLeft; i++) {
if (mLeft % i == 0) {
var cnt = 0;
while (mLeft % i == 0) {
cnt++;
mLeft /= i;
}
ans *= ModCombination(cnt + n - 1, n - 1, devisor);
ans %= devisor;
}
}
if (mLeft != 1) {
ans *= ModCombination(1 + n - 1, n - 1, devisor);
ans %= devisor;
}
Console.WriteLine(ans);
}
public static long ModCombination(long n, long r, int devisor) {
if (r > n - r)
return ModCombination(n, n - r, devisor);
var molecule = 1L;
var denominator = 1L;
for (var i = 0L; i < r; i++) {
molecule *= n - i;
molecule %= devisor;
denominator *= i + 1;
denominator %= devisor;
}
return molecule * ModPow(denominator, devisor - 2, devisor) % devisor;
}
public static long ModPow(long value, int power, int devisor) {
if (power == 0)
return 1L;
if (power % 2 == 0) {
int halfPower = power / 2;
long halfResult = ModPow(value, halfPower, devisor);
return halfResult * halfResult % devisor;
} else {
return value * ModPow(value, power - 1, devisor) % devisor;
}
}
}
class Scanner {
string[] s;
long i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int Nextint() { return int.Parse(Next()); }
public int[] Arrayint(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Nextint() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (long i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(long N, double add = 0) {
double[] Array = new double[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
public decimal NextDecimal() { return decimal.Parse(Next()); }
public decimal[] ArrayDecimal(long N, decimal add = 0) {
decimal[] Array = new decimal[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDecimal();
}
return Array;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 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], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 31, 16, 31, 16, 31, 16, 12, 5, 0, 222], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 17, 72], ["-", 0, 28, 0, 16, 31, 16, 31, 16, 12, 22], ["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 72], ["-", 0, 28, 0, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 28, 0, 16, 31, 16, 12, 5, 0, 222], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 831
| 23
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive {
internal class Solution {
public int N, M;
public long MOD = 1000000007;
public void Run() {
{
var line = Input.ReadIntArray();
N = line[0];
M = line[1];
}
var primes = Primes();
var comb = new FermatCombination(110000);
var counts = new int[primes.Count];
for (int i = 0; i < primes.Count; i++) {
while (M % primes[i] == 0) {
counts[i]++;
M /= primes[i];
}
}
long ret = 1;
for (int i = 0; i < primes.Count; i++) {
ret *= comb.Combination(counts[i] + N - 1, counts[i]);
ret %= MOD;
}
Console.WriteLine(ret);
}
public List<int> Primes() {
int MX = 100000;
var tbl = new bool[MX + 1];
var ret = new List<int>();
for (int i = 2; i <= MX; i++) {
if (tbl[i])
continue;
ret.Add(i);
for (int j = i * 2; j <= MX; j += i) {
tbl[j] = true;
}
}
return ret;
}
}
// libs ----------
// ใใงใซใใผใฎๅฎ็ใ้ๅ
ใไฝฟใๅ ดๅ
class FermatCombination {
public long[] Factrial; // ้ไน
public long[] Inverse; // ้ๅ
public long MOD = 1000000007;
public FermatCombination(int n) {
Factrial = new long[n + 1];
Inverse = new long[n + 1];
Factrial[0] = 1;
Inverse[0] = 1;
for (int i = 1; i <= n; i++) {
Factrial[i] = (Factrial[i - 1] * i) % MOD;
}
for (int i = 1; i <= n; i++) {
// ใใงใซใใผใฎๅฐๅฎ็ใง้ๅ
ใๆฑใใ
Inverse[i] = Power(Factrial[i], (int)MOD - 2, MOD) % MOD;
}
}
public long Permutation(int n, int k) {
return Factrial[n] * Inverse[n - k] % MOD;
}
public long Combination(int n, int k) {
return Factrial[n] * Inverse[k] % MOD * Inverse[n - k] % MOD;
}
public static long Power(long x, long n, long M) {
long tmp = 1;
if (n > 0) {
tmp = Power(x, n / 2, M);
if (n % 2 == 0)
tmp = (tmp * tmp) % M;
else
tmp = (((tmp * tmp) % M) * x) % M;
}
return tmp;
}
}
// common ----------
internal static class Input {
public static string ReadString() {
string line = Console.ReadLine();
return line;
}
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() {
string line = Console.ReadLine();
return long.Parse(line);
}
public static long[] ReadLongArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(double.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive {
internal class Solution {
public int N, M;
public long MOD = 1000000007;
public void Run() {
{
var line = Input.ReadIntArray();
N = line[0];
M = line[1];
}
var primes = Primes();
var comb = new FermatCombination(110000);
var PN = primes.Count + 1;
var counts = new int[PN];
for (int i = 0; i < primes.Count; i++) {
while (M % primes[i] == 0) {
counts[i]++;
M /= primes[i];
}
}
if (M > 1)
counts[PN - 1] = 1;
long ret = 1;
for (int i = 0; i < PN; i++) {
ret *= comb.Combination(counts[i] + N - 1, counts[i]);
ret %= MOD;
}
Console.WriteLine(ret);
}
public List<int> Primes() {
int MX = 100000;
var tbl = new bool[MX + 1];
var ret = new List<int>();
for (int i = 2; i <= MX; i++) {
if (tbl[i])
continue;
ret.Add(i);
for (int j = i * 2; j <= MX; j += i) {
tbl[j] = true;
}
}
return ret;
}
}
// libs ----------
// ใใงใซใใผใฎๅฎ็ใ้ๅ
ใไฝฟใๅ ดๅ
class FermatCombination {
public long[] Factrial; // ้ไน
public long[] Inverse; // ้ๅ
public long MOD = 1000000007;
public FermatCombination(int n) {
Factrial = new long[n + 1];
Inverse = new long[n + 1];
Factrial[0] = 1;
Inverse[0] = 1;
for (int i = 1; i <= n; i++) {
Factrial[i] = (Factrial[i - 1] * i) % MOD;
}
for (int i = 1; i <= n; i++) {
// ใใงใซใใผใฎๅฐๅฎ็ใง้ๅ
ใๆฑใใ
Inverse[i] = Power(Factrial[i], (int)MOD - 2, MOD) % MOD;
}
}
public long Permutation(int n, int k) {
return Factrial[n] * Inverse[n - k] % MOD;
}
public long Combination(int n, int k) {
return Factrial[n] * Inverse[k] % MOD * Inverse[n - k] % MOD;
}
public static long Power(long x, long n, long M) {
long tmp = 1;
if (n > 0) {
tmp = Power(x, n / 2, M);
if (n % 2 == 0)
tmp = (tmp * tmp) % M;
else
tmp = (((tmp * tmp) % M) * x) % M;
}
return tmp;
}
}
// common ----------
internal static class Input {
public static string ReadString() {
string line = Console.ReadLine();
return line;
}
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() {
string line = Console.ReadLine();
return long.Parse(line);
}
public static long[] ReadLongArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(double.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
[["+", 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, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 214, 0, 131], ["+", 0, 200, 0, 212, 0, 16, 31, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 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], ["+", 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, 57, 64, 1, 0, 11, 31, 204, 205, 22], ["+", 64, 1, 0, 11, 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], ["+", 64, 1, 0, 11, 31, 204, 206, 207, 0, 73], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 205, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 0, 131], ["-", 8, 196, 0, 7, 15, 16, 12, 214, 141, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22]]
| 8
| 811
| 32
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
ReadData re;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
re = new ReadData();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int N = re.i();
long M = re.l();
PrimeFactor P = new PrimeFactor(100000);
Fact F = new Fact(1000000);
int[] D = P.PrimeDivide(M);
int c = 1;
long count = 1;
for (int i = 1; i < D.Length; i++) {
if (D[i] == D[i - 1]) {
c++;
} else {
count *= F.GetConv(c + N - 1, c);
count %= Define.mod;
c = 1;
}
}
count *= F.GetConv(c + N - 1, c);
count %= Define.mod;
sb.Append(count + "\n");
}
}
class Fact {
public long[] f;
public long[] rf;
public Fact(int N) {
f = new long[N + 1];
rf = new long[N + 1];
for (int i = 0; i < N + 1; i++) {
if (i == 0) {
f[i] = 1;
} else {
f[i] = (f[i - 1] * i) % Define.mod;
}
}
for (int i = N; i >= 0; i--) {
if (i == N) {
rf[i] = pow(f[N], Define.mod - 2);
} else {
rf[i] = rf[i + 1] * (i + 1) % Define.mod;
}
}
}
public long pow(long N, long K) {
if (K == 0) {
return 1;
} else if (K % 2 == 0) {
long t = pow(N, K / 2);
return t * t % Define.mod;
} else {
return N * pow(N, K - 1) % Define.mod;
}
}
public long GetFact(int N) { return f[N]; }
public long GetPerm(int N, int R) { return f[N] * rf[N - R] % Define.mod; }
public long GetConv(int N, int R) {
return ((f[N] * rf[R]) % Define.mod * rf[N - R]) % Define.mod;
}
public long GetRev(int N) {
if (N == 0) {
return 1;
} else {
return rf[N] * f[N - 1] % Define.mod;
}
}
}
class PrimeFactor {
int[] LowestPrimeFactor;
int[] Prime;
int N;
public PrimeFactor(int N0) {
N = N0;
N++;
LowestPrimeFactor = new int[N];
List<int> prime = new List<int>();
for (int i = 1; i < N; i++) {
LowestPrimeFactor[i] = i;
}
for (int i = 2; i < N; i++) {
if (LowestPrimeFactor[i] == i) {
prime.Add(i);
}
for (int j = 0; j < prime.Count; j++) {
if (prime[j] * i < N && prime[j] <= LowestPrimeFactor[i]) {
LowestPrimeFactor[prime[j] * i] = prime[j];
} else {
break;
}
}
}
Prime = prime.ToArray();
}
public int[] PrimeDivide(int X) {
List<int> ans = new List<int>();
while (X != 1) {
ans.Add(LowestPrimeFactor[X]);
X /= LowestPrimeFactor[X];
}
return ans.ToArray();
}
public int[] PrimeDivide(long X0) {
List<int> ans = new List<int>();
int X = (int)X0;
int i = 0;
while (X >= N) {
if (X % Prime[i] == 0) {
ans.Add(Prime[i]);
X /= Prime[i];
} else {
i++;
if (i == Prime.Length) {
ans.Add(X);
X = 1;
}
}
}
while (X != 1) {
ans.Add(LowestPrimeFactor[X]);
X /= LowestPrimeFactor[X];
}
return ans.ToArray();
}
public int[] Divisor(int X) {
List<int> ans = new List<int>();
ans.Add(1);
while (X != 1) {
int p = LowestPrimeFactor[X];
int c = 0;
while (X % p == 0) {
X /= p;
c++;
}
int l = ans.Count;
int d = p;
for (int i = 1; i <= c; i++) {
for (int j = 0; j < l; j++) {
ans.Add(d * ans[j]);
}
d *= p;
}
}
return ans.ToArray();
}
public int[] Divisor(long X0) {
List<int> ans = new List<int>();
int X = (int)X0;
ans.Add(1);
int i = 0;
while (X >= N) {
if (X % Prime[i] == 0) {
int p = Prime[i];
int c = 0;
while (X % p == 0) {
X /= p;
c++;
}
int l = ans.Count;
int d = p;
for (int k = 1; k <= c; k++) {
for (int j = 0; j < l; j++) {
ans.Add(d * ans[j]);
}
d *= p;
}
} else {
i++;
if (i == Prime.Length) {
int l = ans.Count;
for (int j = 0; j < l; j++) {
ans.Add(X * ans[j]);
}
X = 1;
}
}
}
while (X != 1) {
int p = LowestPrimeFactor[X];
int c = 0;
while (X % p == 0) {
X /= p;
c++;
}
int l = ans.Count;
int d = p;
for (int k = 1; k <= c; k++) {
for (int j = 0; j < l; j++) {
ans.Add(d * ans[j]);
}
d *= p;
}
}
return ans.ToArray();
}
public int Phi(int X) {
int ans = X;
while (X != 1) {
int p = LowestPrimeFactor[X];
while (X % p == 0) {
X /= p;
}
ans /= p;
ans *= p - 1;
}
return ans;
}
public int Phi(long X0) {
int ans = (int)X0;
int X = (int)X0;
int i = 0;
while (X >= N) {
if (X % Prime[i] == 0) {
int p = Prime[i];
while (X % p == 0) {
X /= p;
}
ans /= p;
ans *= p - 1;
} else {
i++;
if (i == Prime.Length) {
int p = X;
ans /= p;
ans *= p - 1;
X = 1;
}
}
}
while (X != 1) {
int p = LowestPrimeFactor[X];
while (X % p == 0) {
X /= p;
}
ans /= p;
ans *= p - 1;
}
return ans;
}
}
class ReadData {
string[] str;
int counter;
public ReadData() { counter = 0; }
public string s() {
if (counter == 0) {
str = Console.ReadLine().Split(' ');
counter = str.Length;
}
counter--;
return str[str.Length - counter - 1];
}
public int i() { return int.Parse(s()); }
public long l() { return long.Parse(s()); }
public double d() { return double.Parse(s()); }
public int[] ia(int N) {
int[] ans = new int[N];
for (int j = 0; j < N; j++) {
ans[j] = i();
}
return ans;
}
public int[] ia() {
str = Console.ReadLine().Split(' ');
counter = 0;
int[] ans = new int[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = int.Parse(str[j]);
}
return ans;
}
public long[] la(int N) {
long[] ans = new long[N];
for (int j = 0; j < N; j++) {
ans[j] = l();
}
return ans;
}
public long[] la() {
str = Console.ReadLine().Split(' ');
counter = 0;
long[] ans = new long[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = long.Parse(str[j]);
}
return ans;
}
public double[] da(int N) {
double[] ans = new double[N];
for (int j = 0; j < N; j++) {
ans[j] = d();
}
return ans;
}
public double[] da() {
str = Console.ReadLine().Split(' ');
counter = 0;
double[] ans = new double[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = double.Parse(str[j]);
}
return ans;
}
public List<int>[] g(int N, int[] f, int[] t) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < f.Length; j++) {
ans[f[j]].Add(t[j]);
ans[t[j]].Add(f[j]);
}
return ans;
}
public List<int>[] g(int N, int M) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
public List<int>[] g() {
int N = i();
int M = i();
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
}
public static class Define { public const long mod = 1000000007; }
public static class Debug {
public static void Print(double[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(double[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(double[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(long[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(long[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(long[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(int[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(int[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(int[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
ReadData re;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
re = new ReadData();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int N = re.i();
long M = re.l();
if (M == 1) {
sb.Append("1\n");
return;
}
PrimeFactor P = new PrimeFactor(100000);
Fact F = new Fact(1000000);
int[] D = P.PrimeDivide(M);
int c = 1;
long count = 1;
for (int i = 1; i < D.Length; i++) {
if (D[i] == D[i - 1]) {
c++;
} else {
count *= F.GetConv(c + N - 1, c);
count %= Define.mod;
c = 1;
}
}
count *= F.GetConv(c + N - 1, c);
count %= Define.mod;
sb.Append(count + "\n");
}
}
class Fact {
public long[] f;
public long[] rf;
public Fact(int N) {
f = new long[N + 1];
rf = new long[N + 1];
for (int i = 0; i < N + 1; i++) {
if (i == 0) {
f[i] = 1;
} else {
f[i] = (f[i - 1] * i) % Define.mod;
}
}
for (int i = N; i >= 0; i--) {
if (i == N) {
rf[i] = pow(f[N], Define.mod - 2);
} else {
rf[i] = rf[i + 1] * (i + 1) % Define.mod;
}
}
}
public long pow(long N, long K) {
if (K == 0) {
return 1;
} else if (K % 2 == 0) {
long t = pow(N, K / 2);
return t * t % Define.mod;
} else {
return N * pow(N, K - 1) % Define.mod;
}
}
public long GetFact(int N) { return f[N]; }
public long GetPerm(int N, int R) { return f[N] * rf[N - R] % Define.mod; }
public long GetConv(int N, int R) {
return ((f[N] * rf[R]) % Define.mod * rf[N - R]) % Define.mod;
}
public long GetRev(int N) {
if (N == 0) {
return 1;
} else {
return rf[N] * f[N - 1] % Define.mod;
}
}
}
class PrimeFactor {
int[] LowestPrimeFactor;
int[] Prime;
int N;
public PrimeFactor(int N0) {
N = N0;
N++;
LowestPrimeFactor = new int[N];
List<int> prime = new List<int>();
for (int i = 1; i < N; i++) {
LowestPrimeFactor[i] = i;
}
for (int i = 2; i < N; i++) {
if (LowestPrimeFactor[i] == i) {
prime.Add(i);
}
for (int j = 0; j < prime.Count; j++) {
if (prime[j] * i < N && prime[j] <= LowestPrimeFactor[i]) {
LowestPrimeFactor[prime[j] * i] = prime[j];
} else {
break;
}
}
}
Prime = prime.ToArray();
}
public int[] PrimeDivide(int X) {
List<int> ans = new List<int>();
while (X != 1) {
ans.Add(LowestPrimeFactor[X]);
X /= LowestPrimeFactor[X];
}
return ans.ToArray();
}
public int[] PrimeDivide(long X0) {
List<int> ans = new List<int>();
int X = (int)X0;
int i = 0;
while (X >= N) {
if (X % Prime[i] == 0) {
ans.Add(Prime[i]);
X /= Prime[i];
} else {
i++;
if (i == Prime.Length) {
ans.Add(X);
X = 1;
}
}
}
while (X != 1) {
ans.Add(LowestPrimeFactor[X]);
X /= LowestPrimeFactor[X];
}
return ans.ToArray();
}
public int[] Divisor(int X) {
List<int> ans = new List<int>();
ans.Add(1);
while (X != 1) {
int p = LowestPrimeFactor[X];
int c = 0;
while (X % p == 0) {
X /= p;
c++;
}
int l = ans.Count;
int d = p;
for (int i = 1; i <= c; i++) {
for (int j = 0; j < l; j++) {
ans.Add(d * ans[j]);
}
d *= p;
}
}
return ans.ToArray();
}
public int[] Divisor(long X0) {
List<int> ans = new List<int>();
int X = (int)X0;
ans.Add(1);
int i = 0;
while (X >= N) {
if (X % Prime[i] == 0) {
int p = Prime[i];
int c = 0;
while (X % p == 0) {
X /= p;
c++;
}
int l = ans.Count;
int d = p;
for (int k = 1; k <= c; k++) {
for (int j = 0; j < l; j++) {
ans.Add(d * ans[j]);
}
d *= p;
}
} else {
i++;
if (i == Prime.Length) {
int l = ans.Count;
for (int j = 0; j < l; j++) {
ans.Add(X * ans[j]);
}
X = 1;
}
}
}
while (X != 1) {
int p = LowestPrimeFactor[X];
int c = 0;
while (X % p == 0) {
X /= p;
c++;
}
int l = ans.Count;
int d = p;
for (int k = 1; k <= c; k++) {
for (int j = 0; j < l; j++) {
ans.Add(d * ans[j]);
}
d *= p;
}
}
return ans.ToArray();
}
public int Phi(int X) {
int ans = X;
while (X != 1) {
int p = LowestPrimeFactor[X];
while (X % p == 0) {
X /= p;
}
ans /= p;
ans *= p - 1;
}
return ans;
}
public int Phi(long X0) {
int ans = (int)X0;
int X = (int)X0;
int i = 0;
while (X >= N) {
if (X % Prime[i] == 0) {
int p = Prime[i];
while (X % p == 0) {
X /= p;
}
ans /= p;
ans *= p - 1;
} else {
i++;
if (i == Prime.Length) {
int p = X;
ans /= p;
ans *= p - 1;
X = 1;
}
}
}
while (X != 1) {
int p = LowestPrimeFactor[X];
while (X % p == 0) {
X /= p;
}
ans /= p;
ans *= p - 1;
}
return ans;
}
}
class ReadData {
string[] str;
int counter;
public ReadData() { counter = 0; }
public string s() {
if (counter == 0) {
str = Console.ReadLine().Split(' ');
counter = str.Length;
}
counter--;
return str[str.Length - counter - 1];
}
public int i() { return int.Parse(s()); }
public long l() { return long.Parse(s()); }
public double d() { return double.Parse(s()); }
public int[] ia(int N) {
int[] ans = new int[N];
for (int j = 0; j < N; j++) {
ans[j] = i();
}
return ans;
}
public int[] ia() {
str = Console.ReadLine().Split(' ');
counter = 0;
int[] ans = new int[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = int.Parse(str[j]);
}
return ans;
}
public long[] la(int N) {
long[] ans = new long[N];
for (int j = 0; j < N; j++) {
ans[j] = l();
}
return ans;
}
public long[] la() {
str = Console.ReadLine().Split(' ');
counter = 0;
long[] ans = new long[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = long.Parse(str[j]);
}
return ans;
}
public double[] da(int N) {
double[] ans = new double[N];
for (int j = 0; j < N; j++) {
ans[j] = d();
}
return ans;
}
public double[] da() {
str = Console.ReadLine().Split(' ');
counter = 0;
double[] ans = new double[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = double.Parse(str[j]);
}
return ans;
}
public List<int>[] g(int N, int[] f, int[] t) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < f.Length; j++) {
ans[f[j]].Add(t[j]);
ans[t[j]].Add(f[j]);
}
return ans;
}
public List<int>[] g(int N, int M) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
public List<int>[] g() {
int N = i();
int M = i();
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
}
public static class Define { public const long mod = 1000000007; }
public static class Debug {
public static void Print(double[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(double[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(double[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(long[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(long[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(long[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(int[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(int[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(int[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
}
|
[["+", 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], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 44], ["+", 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
| 3,231
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp14 {
class Class15 {
static void Main() {
var nx = Console.ReadLine().Split();
int x = int.Parse(nx[1]);
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
Array.Sort(a);
int ans = 0;
for (int i = 0; i < a.Count(); i++) {
if (a[i] <= x) {
ans++;
x -= a[i];
}
}
if (x > 0)
ans--;
Console.WriteLine(ans > 0 ? ans : 0);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp14 {
class Class15 {
static void Main() {
var nx = Console.ReadLine().Split();
int x = int.Parse(nx[1]);
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
Array.Sort(a);
int ans = 0;
for (int i = 0; i < a.Count(); i++) {
if (a[i] <= x) {
ans++;
x -= a[i];
} else {
x = 0;
break;
}
}
if (x > 0)
ans--;
Console.WriteLine(ans > 0 ? ans : 0);
}
}
}
|
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 75, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 75, 196, 0, 93, 0, 35], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
| 8
| 167
| 9
|
using System;
using System.IO;
class Solve {
static void Main(string[] args) {
var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var N = arr[0];
var x = arr[1];
Array.Sort(a);
var answer = 0;
int i = 0;
for (; i < N; i++) {
if (a[i] > x)
break;
answer++;
x -= a[i];
}
if (x > 0 && i == N - 1 && answer > 0)
answer--;
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
using System;
using System.IO;
class Solve {
static void Main(string[] args) {
var arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
var N = arr[0];
var x = arr[1];
Array.Sort(a);
var answer = 0;
for (int i = 0; i < N; i++) {
if (a[i] > x) {
x = 0;
break;
}
answer++;
x -= a[i];
}
if (x > 0 && answer > 0)
answer--;
var writer =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(writer);
Console.WriteLine(answer);
Console.Out.Flush();
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 88], ["+", 8, 201, 0, 195, 8, 196, 0, 7, 0, 24], ["-", 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, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 17, 60], ["-", 15, 16, 31, 16, 12, 16, 12, 16, 31, 22], ["-", 15, 16, 31, 16, 12, 16, 12, 16, 17, 33], ["-", 15, 16, 31, 16, 12, 16, 12, 16, 12, 203]]
| 8
| 192
| 17
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var N = int.Parse(input[0]);
long x = int.Parse(input[1]);
var A = Console.ReadLine().Split(" ").Select(long.Parse).ToArray();
Array.Sort(A);
Array.Reverse(A);
var count = 0;
for (var i = 0; i < N; i++) {
if (x >= A[i]) {
x -= A[i];
count++;
}
}
if (x > 0 && count == A.Length)
count--;
Console.WriteLine(count);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var N = int.Parse(input[0]);
long x = int.Parse(input[1]);
var A = Console.ReadLine().Split(" ").Select(long.Parse).ToArray();
Array.Sort(A);
var count = 0;
for (var i = 0; i < N; i++) {
if (x >= A[i]) {
x -= A[i];
count++;
}
}
if (x > 0 && count == A.Length)
count--;
Console.WriteLine(count);
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 170
| 7
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var x = int.Parse(spl[1]);
var ary = ToIntArray(input.ReadLine(), n);
Array.Sort(ary);
int count = 0;
for (int i = 0; i < n; i++) {
var a = ary[i];
if (x >= a) {
x -= a;
count++;
}
}
return count;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const char White = '.';
const char Black = '#';
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var x = int.Parse(spl[1]);
var ary = ToIntArray(input.ReadLine(), n);
Array.Sort(ary);
int count = 0;
for (int i = 0; i < n - 1; i++) {
var a = ary[i];
if (x >= a) {
x -= a;
count++;
}
}
if (x == ary[n - 1])
count++;
return count;
}
static int[] ToIntArray(string strs, int n) {
var ret = new int[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = int.Parse(spl[i]);
return ret;
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 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], ["+", 8, 196, 0, 57, 15, 16, 12, 204, 205, 22], ["+", 0, 57, 15, 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, 57, 15, 16, 12, 204, 206, 207, 0, 73], ["+", 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
| 317
| 16
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var nx = Reads();
var n = nx[0];
var x = nx[1];
var a = Reads();
Array.Sort(a);
long sum = 0;
long ans = 0;
for (int i = 0; i < n; i++) {
if (sum + a[i] <= x) {
sum += a[i];
ans = i + 1;
}
}
Console.WriteLine(sum == x ? ans : ans - 1);
Console.Out.Flush();
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
namespace atcorder2 {
class Program {
public static long Read() { return long.Parse(Console.ReadLine()); }
public static long[] Reads() {
return Console.ReadLine().Split().Select(long.Parse).ToArray();
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var nx = Reads();
var n = nx[0];
var x = nx[1];
var a = Reads();
Array.Sort(a);
long sum = 0;
long ans = 0;
for (int i = 0; i < n; i++) {
if (a[i] <= x) {
x -= a[i];
ans = i + 1;
}
}
Console.WriteLine(x != 0 && ans == n ? ans - 1 : ans);
Console.Out.Flush();
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["-", 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, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 31, 22], ["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 17, 79], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 98], ["-", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 17, 60], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 22]]
| 8
| 228
| 18
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Ints;
var N = o[0];
var x = o[1];
var A = Ints;
Array.Sort(A);
int ans = 0;
for (int i = 0; i < N; ++i) {
if (x - A[i] < 0) {
Write(ans);
return;
}
x -= A[i];
ans++;
}
Write(ans);
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long i, long N, long MOD = 1000000007) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long Power2(long i, long N) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i;
i = i * i;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Numerics;
using System.IO;
using System.Runtime.InteropServices;
using static System.Math;
using static Math2;
using static io;
using static Utils;
public class CompetitiveProgramming {
public void Solve() {
var o = Ints;
var N = o[0];
var x = o[1];
var A = Ints;
Array.Sort(A);
int ans = 0;
for (int i = 0; i < N; ++i) {
if (x - A[i] < 0) {
Write(ans);
return;
}
x -= A[i];
ans++;
}
if (x != 0)
--ans;
Write(ans);
}
}
public static class Math2 {
public const int INF = 1 << 29;
public const long INFL = 1L << 60;
public const long MOD = 1000000007;
public const int MOD2 = 998244353;
public static long Power(long i, long N, long MOD = 1000000007) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i % MOD;
i = i * i % MOD;
N >>= 1;
}
return res;
}
public static long Power2(long i, long N) // i^N
{
long res = 1;
while (N > 0) {
if ((N & 1) != 0)
res = res * i;
i = i * i;
N >>= 1;
}
return res;
}
public static long GCD(long i, long N) {
if (i > N)
Swap(ref i, ref N);
if (i == 0)
return N;
while (N != 0) {
var r = i % N;
i = N;
N = r;
}
return i;
}
public static long LCM(long i, long N) => i * N / GCD(i, N);
public static long Comb(long N, long R, int MOD = 1000000007) {
long ret = 1;
long x = 1;
for (long i = N; i >= N - R + 1; --i) {
ret = ret / x * i;
ret %= MOD;
x++;
}
return ret;
}
public static long Comb2(long N, long R) {
long Nume = 1;
long Deno = 1;
if (R > N - R)
Swap(ref N, ref R);
for (long i = 1; i <= R; ++i) {
Deno *= i;
Nume *= N - i + 1;
}
return Deno / Nume;
}
}
public static class Utils {
public static void Swap<T>(ref T A, ref T B) {
T x = A;
A = B;
B = x;
}
public static int DigitSum(int N) {
string s = N.ToString();
int ret = 0;
for (int i = 0; i < s.Length; ++i)
ret += s[i] - '0';
return ret;
}
}
class Program {
static void Main(string[] args) {
var CompetitiveProgramming = new CompetitiveProgramming();
CompetitiveProgramming.Solve();
}
}
public static class io {
public static string Str => Console.ReadLine();
public static string[] Strs => Str.Split(' ');
public static long[] Longs => Strs.Select(long.Parse).ToArray();
public static int[] Ints => Strs.Select(int.Parse).ToArray();
public static char[] Chars => Str.ToArray();
public static double[] Doubles => Strs.Select(double.Parse).ToArray();
public static long Long1 => Longs[0];
public static int Int1 => Ints[0];
public static char Char1 => Chars[0];
public static double Double1 => Doubles[0];
public static long[] VerticalRead(int N) {
long[] A = new long[N];
for (int i = 0; i < N; ++i)
A[i] = Long1;
return A;
}
public static void Write(string a) => Console.WriteLine(a);
public static void Write(params object[] i) => Write(string.Join(" ", i));
public static void Write<T>(IEnumerable<T> a) => Write(string.Join(" ", a));
public static void Verticalwrite<T>(IEnumerable<T> a) {
foreach (var z in a)
Write(z);
}
public static void YN(bool i) {
if (i)
Write("Yes");
else
Write("No");
}
}
|
[["+", 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, 241, 0, 68], ["+", 8, 196, 0, 57, 64, 1, 0, 241, 0, 22], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 1,005
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int x = sc.NextInt();
int[] a = sc.IntArray();
a = a.OrderBy(_a => _a).ToArray();
int answer = 0;
for (int i = 0; i < n; i++) {
if (x >= a[i]) {
answer++;
x -= a[i];
} else {
break;
}
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderA {
static void Main() {
var sc = new Scanner();
int n = sc.NextInt();
int x = sc.NextInt();
int[] a = sc.IntArray();
a = a.OrderBy(_a => _a).ToArray();
int answer = 0;
for (int i = 0; i < n; i++) {
if (x >= a[i]) {
answer++;
x -= a[i];
} else {
break;
}
}
if (answer == n && x > 0) {
answer--;
}
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["+", 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, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 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, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 432
| 15
|
using System;
namespace agc027A {
class MainClass {
public static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int N = int.Parse(str[0]);
int x = int.Parse(str[1]);
int[] a = new int[N];
string[] src = Console.ReadLine().Split();
for (int i = 0; i < N; i++) {
a[i] = int.Parse(src[i]);
}
Array.Sort(a);
int Ans = 0;
int B = x;
for (int i = 0; i < N; i++) {
B = B - a[i];
if (B >= 0)
Ans += 1;
}
if (B > 0) {
Ans -= 1;
}
Console.WriteLine(Ans);
}
}
}
|
using System;
namespace agc027A {
class MainClass {
public static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
long N = long.Parse(str[0]);
long x = long.Parse(str[1]);
long[] a = new long[N];
string[] src = Console.ReadLine().Split();
for (int i = 0; i < N; i++) {
a[i] = long.Parse(src[i]);
}
Array.Sort(a);
int Ans = 0;
long B = x;
for (int i = 0; i < N; i++) {
B = B - a[i];
if (B >= 0)
Ans += 1;
}
if (B > 0)
Ans -= 1;
Console.WriteLine(Ans);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 192
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
using static AtCoder.CalcL;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dI = { 0, 1, 0, -1 };
static readonly int[] dJ = { 1, 0, -1, 0 };
static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>>G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
var input = cin.ReadSplitInt();
int N = input[0];
int x = input[1];
var a = cin.ReadSplitInt();
Sort(a);
long ans = 0;
for (var i = 0; i < N; i++) {
if (x < a[i]) {
break;
}
ans++;
x -= a[i];
}
if (x != 0 && ans > 0) {
ans--;
}
Console.WriteLine(ans);
// Console.Out.Flush();
}
struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
public class Scanner {
public int[] ReadSplitInt() {
return ConvertAll(Console.ReadLine().Split(), int.Parse);
}
public long[] ReadSplitLong() {
return ConvertAll(Console.ReadLine().Split(), long.Parse);
}
public double[] ReadSplit_Double() {
return ConvertAll(Console.ReadLine().Split(), double.Parse);
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static public long LPow(int a, int b) { return (long)Pow(a, b); }
}
static public class CalcI {
public static int Gcd(int a, int b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static int Lcm(int a, int b) {
int g = Gcd(a, b);
return a / g * b;
}
public static int Ceil(int n, int div) { return (n + div - 1) / div; }
}
static public class CalcL {
public static long Gcd(long a, long b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static long Lcm(long a, long b) {
long g = Gcd(a, b);
return a / g * b;
}
public static long Ceil(long n, long div) { return (n + div - 1) / div; }
}
class Modulo {
private const int M = 1000000007;
private readonly int[] m_facs;
public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % M); }
public Modulo(int n) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i) {
m_facs[i] = Mul(m_facs[i - 1], i);
}
}
public int Fac(int n) { return m_facs[n]; }
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Mul(p1, p1);
return ((m % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Div(int a, int b) { return Mul(a, Pow(b, M - 2)); }
public int Ncr(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
public Modulo() {}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
using static AtCoder.CalcL;
namespace AtCoder {
class AC {
const int MOD = 1000000007;
const int INF = int.MaxValue / 2;
const long SINF = long.MaxValue / 2;
const double EPS = 1e-8;
static readonly int[] dI = { 0, 1, 0, -1 };
static readonly int[] dJ = { 1, 0, -1, 0 };
static List<List<int>> G = new List<List<int>>();
// static List<List<Edge>>G = new List<List<Edge>>();
// static List<Edge> E = new List<Edge>();
static void Main(string[] args) {
// var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush =
// false }; Console.SetOut(sw);
var cin = new Scanner();
var input = cin.ReadSplitInt();
int N = input[0];
int x = input[1];
var a = cin.ReadSplitInt();
Sort(a);
long ans = 0;
for (var i = 0; i < N; i++) {
if (x < a[i]) {
break;
}
ans++;
x -= a[i];
}
if (ans == N && x != 0) {
ans--;
}
Console.WriteLine(ans);
// Console.Out.Flush();
}
struct Edge {
public int from;
public int to;
public long dist;
public Edge(int t, long c) {
from = -1;
to = t;
dist = c;
}
public Edge(int f, int t, long c) {
from = f;
to = t;
dist = c;
}
}
}
public class Scanner {
public int[] ReadSplitInt() {
return ConvertAll(Console.ReadLine().Split(), int.Parse);
}
public long[] ReadSplitLong() {
return ConvertAll(Console.ReadLine().Split(), long.Parse);
}
public double[] ReadSplit_Double() {
return ConvertAll(Console.ReadLine().Split(), double.Parse);
}
}
public static class Tool {
static public void Initialize<T>(ref T[] array, T initialvalue) {
for (var i = 0; i < array.Length; i++) {
array[i] = initialvalue;
}
}
static public void Swap<T>(ref T a, ref T b) {
T keep = a;
a = b;
b = keep;
}
static public void Display<T>(T[,] array2d, int n, int m) {
for (var i = 0; i < n; i++) {
for (var j = 0; j < m; j++) {
Console.Write($"{array2d[i, j]} ");
}
Console.WriteLine();
}
}
static public long LPow(int a, int b) { return (long)Pow(a, b); }
}
static public class CalcI {
public static int Gcd(int a, int b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static int Lcm(int a, int b) {
int g = Gcd(a, b);
return a / g * b;
}
public static int Ceil(int n, int div) { return (n + div - 1) / div; }
}
static public class CalcL {
public static long Gcd(long a, long b) {
if (a * b == 0) {
return Max(a, b);
}
return a % b == 0 ? b : Gcd(b, a % b);
}
public static long Lcm(long a, long b) {
long g = Gcd(a, b);
return a / g * b;
}
public static long Ceil(long n, long div) { return (n + div - 1) / div; }
}
class Modulo {
private const int M = 1000000007;
private readonly int[] m_facs;
public int Mul(int a, int b) { return (int)(Math.BigMul(a, b) % M); }
public Modulo(int n) {
m_facs = new int[n + 1];
m_facs[0] = 1;
for (int i = 1; i <= n; ++i) {
m_facs[i] = Mul(m_facs[i - 1], i);
}
}
public int Fac(int n) { return m_facs[n]; }
public int Pow(int a, int m) {
switch (m) {
case 0:
return 1;
case 1:
return a;
default:
int p1 = Pow(a, m / 2);
int p2 = Mul(p1, p1);
return ((m % 2) == 0) ? p2 : Mul(p2, a);
}
}
public int Div(int a, int b) { return Mul(a, Pow(b, M - 2)); }
public int Ncr(int n, int r) {
if (n < r) {
return 0;
}
if (n == r) {
return 1;
}
int res = Fac(n);
res = Div(res, Fac(r));
res = Div(res, Fac(n - r));
return res;
}
public Modulo() {}
}
}
|
[["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 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, 47]]
| 8
| 1,125
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var nx = ReadSplitLong();
var n = nx[0];
var x = nx[1];
var a = ReadSplitLong().OrderBy(z => z).ToArray();
var ans = 0;
for (int i = 0; i < n; i++) {
if (a[i] <= x) {
x -= a[i];
ans++;
} else {
break;
}
}
if (ans > 0 && x > 0)
ans--;
Println(ans);
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static void YESOrNO(bool e) => Println(e ? "YES" : "NO");
static void YesOrNo(bool e) => Println(e ? "Yes" : "No");
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var nx = ReadSplitLong();
var n = nx[0];
var x = nx[1];
var a = ReadSplitLong().OrderBy(z => z).ToArray();
var ans = 0;
var f = true;
for (int i = 0; i < n; i++) {
if (a[i] <= x) {
x -= a[i];
ans++;
} else {
f = false;
}
}
if (f && x > 0)
ans--;
Println(ans);
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static void YESOrNO(bool e) => Println(e ? "YES" : "NO");
static void YesOrNo(bool e) => Println(e ? "Yes" : "No");
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 146], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 57, 75, 196, 0, 93, 0, 94], ["+", 0, 57, 75, 196, 0, 1, 0, 11, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 211, 0, 147], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 779
| 13
|
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
class P {
static void Main() {
int[] nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x = nx[1];
int[] a =
Console.ReadLine().Split().Select(int.Parse).OrderBy(p => p).ToArray();
int count = 0;
for (int i = 0; i < a.Length; i++) {
x -= a[i];
if (x < 0) {
Console.WriteLine(count);
return;
} else {
count++;
}
}
Console.WriteLine(count);
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;
class P {
static void Main() {
int[] nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x = nx[1];
int[] a =
Console.ReadLine().Split().Select(int.Parse).OrderBy(p => p).ToArray();
int count = 0;
for (int i = 0; i < a.Length; i++) {
x -= a[i];
if (x < 0) {
Console.WriteLine(count);
return;
} else {
count++;
}
}
if (x > 0)
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, 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, 68], ["+", 0, 195, 8, 196, 0, 57, 64, 1, 0, 35]]
| 8
| 198
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace AIZUproject07 {
class Program {
// static string T;
/*static void Main()
{
int count = 0;
bool flag = false;
string In = Console.ReadLine();
string[] s = Console.ReadLine().Split();
int[] aa = s.Select(int.Parse).ToArray();
while (true)
{
for (int i = 0; i < aa.Length; i++)
{
if (aa[i] % 2 != 0)
{
flag = true;
}
}
aa = aa.Select(n => n / 2).ToArray();
if (flag == true) break;
count++;
}
Console.WriteLine(count);
}*/
/*static void Main()
{
int sum = 0;
int count = 0;
string A = Console.ReadLine();
string B = Console.ReadLine();
string C = Console.ReadLine();
string D = Console.ReadLine();
int AA = int.Parse(A);
int BB = int.Parse(B);
int CC = int.Parse(C);
int DD = int.Parse(D);
for(int i = 0;i<=AA;i++)
{
for (int j=0;j<=BB;j++)
{
for (int k =0;k<=CC;k++)
{
sum = i * 500 + j * 100 + k * 50;
if (sum == DD) count++;
}
}
}
Console.WriteLine(count);
}*/
/*static void Main()
{
int ans1 = 0;
int ans2 = 0;
string[] s = Console.ReadLine().Split();
int[] intArray = s.Select(int.Parse).ToArray();
for (int i = 1;i<=intArray[0];i++)
{
ans1 = 0;
if (i >= 10 && i <100)
{
var aaa = i % 10;
var bbb = i / 10;
ans1 = aaa + bbb;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i >= 100 && i<1000)
{
var aaa = i % 10;
var bbb = i / 10;
var ccc = bbb % 10;
var ddd = bbb / 10;
ans1 = aaa + ccc + ddd;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i >= 1000 && i <10000)
{
var aaa = i % 10;//4
var bbb = i / 10;
var ccc = bbb % 10;//3
var ddd = bbb / 10;
var eee = ddd % 10;//2
var fff = ddd / 10;//1
ans1 = aaa + ccc + eee + fff;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i == 10000)
{
ans1 = 1;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i < 10)
{
ans1 = i;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
}
Console.WriteLine(ans2);
}*/
/*static void Main()
{
int sum = 0;
bool test = false;
string[] aa = Console.ReadLine().Split();
int N = int.Parse(aa[0]);
int Y = int.Parse(aa[1]);
int Yukichi = Y / 10000;
int Ichiyo = Y / 5000;
int Hideyo = Y / 1000;
int x = 0;
int y = 0;
int z = 0;
for (int i = 0;i<=Yukichi;i++)
{
for (int j =0;j<=Ichiyo;j++)
{
for (int k =0;k<=Hideyo;k++)
{
sum = 10000 * i + 5000 * j + 1000 * k;
if (sum == Y && i+j+k < N)
{
x = i;
y = j;
z = k;
//Console.WriteLine(i + " " + j + " " + k);
test = true;
}
}
}
}
if (test == true)
{
Console.WriteLine(x + " " + y + " " + z);
}
if (test == false)
{
Console.WriteLine("-1 -1 -1");
}
}*/
/*static void Main()
{
string[] aa = Console.ReadLine().Split();
int N = int.Parse(aa[0]);
int Y = int.Parse(aa[1]);
int X = 0;
int Z = 0;
int b = 0;
int d = 0;
X = Y / 10000;
var a = Y - (X*10000);
if (a != 0 || Y < 10000)
{
b = a / 5000;
var cc = a - (b * 5000);
if (cc != 0 || a < 5000)
{
d = cc / 1000;
var gg = cc - (d * 1000);
if (gg != 0 || cc<1000)
{
Console.WriteLine("-1 -1 -1");
}
else if (X + b + d <= N)
{
Console.WriteLine(X + " " + b + " " + d);
}
else if (X + b + d > N)
{
Console.WriteLine("-1 -1 -1");
}
}
else if (X + b <= N)
{
Console.WriteLine(X +" "+ b +" "+"0");
}
else if (X + b > N)
{
Console.WriteLine("-1 -1 -1");
}
}
else if (X <= N)
{
Console.WriteLine(X +" "+0+" "+0);
}
else if (X>N)
{
Console.WriteLine("-1 -1 -1");
}
}*/
/*static void Main()
{
string s = Console.ReadLine();
var Ans = s.Replace("eraser", "").Replace("dreamer",
"").Replace("dreamer", "").Replace("erase", "").ToString(); if (Ans == null)
Console.WriteLine("YES"); else Console.WriteLine("NO");*/
// List<string> str = new List<string>(); || s.Substring(5, 1) == ""
// string NN = new string(s); || s.Substring(5,1) == ""
/*while (true) {
while (true)
{
if (s.StartsWith("dream") && (s.Substring(5,2) != "er" ))
{
count++;
var f = s.Remove(0, 5);
s = f;
break;
}
if (s.StartsWith("dreamer"))
{
var n = s.Remove(0, 7);
s = n;
break;
}
if (s.StartsWith("erase") || (s.Substring(5,1) != "r" ))
{
count2++;
var f1 = s.Remove(0, 5);
s = f1;
break;
}
if (s.StartsWith("eraser"))
{
var f2 = s.Remove(0, 6);
s = f2;
break;
}
else
{
tt = true;
break;
}
}
if (s.Length == 0)
{
Console.WriteLine("YES");
break;
}
if (tt)
{
Console.WriteLine("NO");
break;
}
}*/
// Console.WriteLine(count+","+count2);
//}
// 86C
/*static void Main()
{
/*string aa = Console.ReadLine();
List<int[]> nn = new List<int[]>();
for (int i = 0;i<aa.Length;i++)
{
string[] str = Console.ReadLine().Split();
int[] intstr = str.Select(int.Parse).ToArray();
nn.Add(intstr);
}
var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
var num = a1[0];
var list = new List<int[]>(num);
for (int i=0;i<num;i++)
{
}
}*/
/*static void Main(string[] args)
{
var input = Console.ReadLine().Split(' ');
var array = input.Select(int.Parse).ToArray();
int num = array[0] * 100 + array[1] * 10 + array[2] * 1;
if (num % 4 == 0)
{
Console.WriteLine("YES");
}
else
{
Console.WriteLine("NO");
}
}*/
/*static void Main()
{
var input = Console.ReadLine();
var a = Console.ReadLine();
int N = int.Parse(input);
int A = int.Parse(a);
bool flag = false;
for (int i = 0;i <= A;i++ )
{
var Ans = N - i;
if (Ans % 500 == 0)
{
Console.WriteLine("Yes");
flag = true;
break;
}
}
if (flag == false)
{
Console.WriteLine("No");
}
}*/
/*static void Main()
{
var a = Console.ReadLine().Split();
double[] integer = a.Select(double.Parse).ToArray();
double ans = (integer[0] + integer[1]) / 2;
Console.WriteLine(Math.Ceiling(ans));
}*/
/*static void Main()
{
int count = 0;
string str = Console.ReadLine();
//var cross = str.Select(n => n != 'ร');
//var circle = str.Select(n => n != 'o');
//Console.WriteLine(cross);
//Console.WriteLine(circle);
/*Console.WriteLine(str.Length);
while (true)
{
Match match1 = Regex.Match(str, "o");
if (match1 != null)
{
count++;
}
str = str.Substring(match1.Index+1, str.Length);
if (match1.Index == str.Length)
{
break;
}
}
var Ans = 700 + count * 100;
Console.WriteLine(Ans);*/
// Console.WriteLine(match.Value);
/*or (int i =0;i<str.Length;i++)
{
if (Regex.Match(str[i], "o"))
{
}
}
count = str.Length - str.Replace("o", "").Length;
var Ans = 700 + count * 100;
Console.WriteLine(Ans);
}*/
/*static void Main()
{
var str = Console.ReadLine();
var Ans = str.Replace("2017","2018");
Console.WriteLine(Ans);
}*/
/*static void Main()
{
var str = Console.ReadLine();
//str.Substring(0, 1) +
Console.WriteLine(str.Substring(0, 1) + (str.Length-2) +
str.Substring(str.Length-1));
}*/
// 82B
/*static void Main()
{
var s = Console.ReadLine();
var t = Console.ReadLine();
char[] S = s.ToArray();
char[] T = t.ToArray();
Array.Sort(S);
Array.Sort(T);Array.Reverse(T);
string ss = new string(S);
string ts = new string(T);
if (ss.CompareTo(ts) < 0)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}*/
// sใซ้ขใใฆใฝใผใ
/*for (int i = 0; i < s.Length; i++)
{
}*/
// var hoge = s.OrderByDescending((x) => x.Value);
/*List<int> array = new List<int>();
int[] rank = new int[s.Length];
for (int i = 0; i < s.Length; i++)
{
rank[i] = 0;
}
for (int i = 0; i < s.Length; i++)
{
for (int j = 0; j < s.Length; j++)
{
if (s[i] > s[j])
{
rank[i]++;
}
}
}
for (int i=0;i<s.Length;i++)
{
for (int j =0;j<s.Length;j++)
{
if (i == rank[j])
{
array.Add(s[i]);
}
}
}
for (int i = 0; i < s.Length; i++)
{
Console.Write(array[i]);
}
}*/
/*static void Main()
{
int count;
int temp = 0;
var N = int.Parse(Console.ReadLine());
List<int> aa = new List<int>();
for (int i = 1; i <= N; i++)
{
count = 0;
temp = i;
while (true)
{
var Ans = temp / 2;
var Ans2 = temp % 2;
if (Ans2 == 0)
{
count++;
temp = Ans;
}
else
{
break;
}
}
aa.Add(count);
}
//Program program = new Program();
//program.Max(aa, temp);
var max = aa.IndexOf(aa.Max());
Console.WriteLine(max+1);
}
public void Max(List<int> array,int num)
{
var Ans3 = array.Max();
}*/
/*static void Main()
{
List<int> array = new List<int>();
var N = Console.ReadLine();
int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (int i = 0;i<A.Length;i++)
{
for (int j = 0; j< A.Length; j++)
{
var ans = A[i] - A[j];
if (ans < 0)
{
ans = Math.Abs(ans);
}
//Console.Write(ans);
array.Add(ans);
}
//Console.WriteLine();
}
Console.WriteLine(array.Max());
}*/
/*static void Main()
{
var N = Console.ReadLine();
int[] temperture = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] height = Console.ReadLine().Split().Select(int.Parse).ToArray();
int T = temperture[0];
int A = temperture[1];
List<double> aa = new List<double>();
List<double> bb = new List<double>();
for (int i = 0;i<height.Length;i++)
{
var temp = T - height[i] * 0.006;
aa.Add(temp);
}
for (int i =0;i<height.Length;i++)
{
var temp = A - aa[i];
if (temp < 0)
{
temp = Math.Abs(temp);
}
bb.Add(temp);
}
Console.WriteLine(bb.IndexOf(bb.Min())+1);
}*/
/*static void Main()
{
string a = Console.ReadLine();
char[] charArray = a.ToArray();
List<char> aa = new List<char>();
for (int i = 0;i<charArray.Length;i++)
{
if ((i+1)%2 == 1)
{
aa.Add(charArray[i]);
}
}
var str = string.Join("",aa);
Console.WriteLine(str);
}*/
// 053B
/*static void Main()
{
var str = Console.ReadLine();
var start = str.IndexOf("A");
var goal = str.IndexOf("Z",start);
string temp = new string(str.Substring(goal).ToArray());
int goalpoint = 0;
List<int> kk = new List<int>();
while (true)
{
if (temp.Contains("Z"))
{
goalpoint = temp.IndexOf("Z") +1;
temp = temp.Replace("Z", "");
}
if (temp.Contains("Z") == false)
{
break;
}
if(temp.Contains("Z"))
{
Console.WriteLine();
}
}
for (int i = 0;i<temp.Length;i++)
{
if (temp[i] == 'Z')
{
goalpoint = i;
}
}
var ans = str.Substring(start, goal-start).Length + 1 + goalpoint;
Console.WriteLine(ans);
}*/
// 095B
/*static void Main()
{
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = a[0];
int X = a[1];
List<int> listarray = new List<int>();
int Ans = 0;
for (int i =0;i < N;i++)
{
var temp = Console.ReadLine();
int temp1 = int.Parse(temp);
listarray.Add(temp1);
}
for (int i =0;i< N;i++)
{
X = X - listarray[i];
if (X >= 0)
{
Ans++;
}
}
if (X > 0)
{
while (true)
{
X = X - listarray.Min();
if (X < 0)
{
break;
}
Ans++;
}
}
Console.WriteLine(Ans);
}*/
// 105B
/*static void Main()
{
int dunats = 7;
int cake = 4;
int sum = 0;
bool flag = false;
int N = int.Parse(Console.ReadLine());
if (N > 3)
{
for (int i = 0; i <= N / cake; i++)
{
for (int j=0; j<=N/dunats;j++)
{
sum = dunats * j + cake * i;
if (sum == N) {
flag = true;
}
if (flag == true)
{
break;
}
}
if (flag == true)
{
break;
}
}
}
if (flag == true) { Console.WriteLine("Yes"); }
else { Console.WriteLine("No"); }
}*/
// 004A
/*static void Main()
{
List<double> Ans = new List<double>();
List<int[]> array = new List<int[]>();
int N = int.Parse(Console.ReadLine());
for (int i = 0; i < N; i++)
{
int[] aa = Console.ReadLine().Split().Select(int.Parse).ToArray();
array.Add(aa);
}
for (int i=0;i<N;i++)
{
for (int j = 0;j<N;j++)
{
var X = array[i][0] - array[j][0];
var Y = array[i][1] - array[j][1];
var resultX = Math.Pow(X, 2);
var resultY = Math.Pow(Y, 2);
var ans = Math.Sqrt(resultX + resultY);
Ans.Add(ans);
}
}
var finalresult = Ans.Max();
Console.WriteLine(finalresult);
}*/
// 51B
/*static void Main()
{
int count = 0;
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int K = input[0];
int S = input[1];
for (int x =0;x<= K;x++)
{
for (int y = 0; y <= K; y++)
{
var z = S - x - y;
if ( 0 <= z && z <= K)
{
count++;
}
}
}
Console.WriteLine(count);
}*/
// 80B
/*static void Main()
{
int Ans = 0;
string x = Console.ReadLine();
int X = int.Parse(x);
for (int i =0;i<x.Length;i++)
{
var temp = Convert.ToInt32(x[i].ToString());
Ans += temp;
}
if (X % Ans == 0)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}*/
// 90B
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int aaa = 0;
int count = 1;
int ko = 0;
string ans ="";
StringBuilder sb = new StringBuilder();
while(true)
{
string X = A.ToString();
count = 1;
ans = "";
//Console.WriteLine(X[X.Length - count]);
while (true)
{
//sb = null;
sb.Append(X[X.Length - count]);
if (X.Length - count == 0)
{
ans = sb.ToString();
break;
}
count++;
}
sb.Remove(0,X.Length);
aaa = int.Parse(ans);
//Console.WriteLine(aaa);
if (A == aaa)
{
ko++;
}
if (A == B)
{
break;
}
A++;
}
Console.WriteLine(ko);
}*/
// 25A
/*static void Main()
{
int ansA = 0;
int ansB = 0;
int N = int.Parse(Console.ReadLine());
List<int> Ans = new List<int>();
for (int A = 1;A<N;A++)
{
int B = N - A;
List<int> la = new List<int>();
List<int> lb = new List<int>();
ansA = 0;
ansB = 0;
string a = A.ToString();
string b = B.ToString();
for (int i =0;i<a.Length;i++)
{
char ca = a[i];
int intca = Convert.ToInt32(ca.ToString());
la.Add(intca);
}
for (int i=0;i<b.Length;i++)
{
char cb = b[i];
int intcb = Convert.ToInt32(cb.ToString());
lb.Add(intcb);
}
foreach(int n in la)
{
ansA += n;
}
foreach (int n in lb)
{
ansB += n;
}
Ans.Add(ansA + ansB);
}
Console.WriteLine(Ans.Min());
}*/
// 67B
/*static void Main()
{
int Ans = 0;
List<int> array = new List<int>();
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int K = input[1];
int[] length = Console.ReadLine().Split().Select(int.Parse).ToArray();
//int[] newone = new int[length.Length];
Array.Sort(length);
Array.Reverse(length);
for (int i = 0;i<K;i++)
{
array.Add(length[i]);
Ans += length[i];
}
Console.WriteLine(Ans);
}*/
// 42B
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int L = input[1];
string[] str = new string[N];
for (int i=0;i<N;i++)
{
var a = Console.ReadLine();
str[i] = a;
}
StringComparer cmp = StringComparer.OrdinalIgnoreCase;
Array.Sort(str,cmp);
List<string> Ans = new List<string>();
for (int i = 0;i<N;i++)
{
Ans.Add(string.Concat(str[i]));
}
StringBuilder sb = new StringBuilder();
for (int i = 0;i<N;i++)
{
sb.Append(Ans[i]);
sb.Append(string.Concat(str[i]));
}
Console.WriteLine(sb);
}*/
// 27A
static void Main() {
int Ans = 0;
int count = 0;
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int x = input[1];
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
Array.Sort(a);
for (int i = 0; i < N; i++) {
Ans += a[i];
if (Ans <= x) {
count++;
}
if (Ans == x) {
Console.WriteLine(N);
}
// x -= a[i];
/*if (x >= 0)
{
if (x >= a[i] x==0)
{
count++;
}
}
else
{
break;
}*/
}
Console.WriteLine(count - 1);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace AIZUproject07 {
class Program {
// static string T;
/*static void Main()
{
int count = 0;
bool flag = false;
string In = Console.ReadLine();
string[] s = Console.ReadLine().Split();
int[] aa = s.Select(int.Parse).ToArray();
while (true)
{
for (int i = 0; i < aa.Length; i++)
{
if (aa[i] % 2 != 0)
{
flag = true;
}
}
aa = aa.Select(n => n / 2).ToArray();
if (flag == true) break;
count++;
}
Console.WriteLine(count);
}*/
/*static void Main()
{
int sum = 0;
int count = 0;
string A = Console.ReadLine();
string B = Console.ReadLine();
string C = Console.ReadLine();
string D = Console.ReadLine();
int AA = int.Parse(A);
int BB = int.Parse(B);
int CC = int.Parse(C);
int DD = int.Parse(D);
for(int i = 0;i<=AA;i++)
{
for (int j=0;j<=BB;j++)
{
for (int k =0;k<=CC;k++)
{
sum = i * 500 + j * 100 + k * 50;
if (sum == DD) count++;
}
}
}
Console.WriteLine(count);
}*/
/*static void Main()
{
int ans1 = 0;
int ans2 = 0;
string[] s = Console.ReadLine().Split();
int[] intArray = s.Select(int.Parse).ToArray();
for (int i = 1;i<=intArray[0];i++)
{
ans1 = 0;
if (i >= 10 && i <100)
{
var aaa = i % 10;
var bbb = i / 10;
ans1 = aaa + bbb;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i >= 100 && i<1000)
{
var aaa = i % 10;
var bbb = i / 10;
var ccc = bbb % 10;
var ddd = bbb / 10;
ans1 = aaa + ccc + ddd;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i >= 1000 && i <10000)
{
var aaa = i % 10;//4
var bbb = i / 10;
var ccc = bbb % 10;//3
var ddd = bbb / 10;
var eee = ddd % 10;//2
var fff = ddd / 10;//1
ans1 = aaa + ccc + eee + fff;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i == 10000)
{
ans1 = 1;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
if (i < 10)
{
ans1 = i;
if (intArray[1] <= ans1 && ans1 <= intArray[2])
{
ans2 += i;
}
}
}
Console.WriteLine(ans2);
}*/
/*static void Main()
{
int sum = 0;
bool test = false;
string[] aa = Console.ReadLine().Split();
int N = int.Parse(aa[0]);
int Y = int.Parse(aa[1]);
int Yukichi = Y / 10000;
int Ichiyo = Y / 5000;
int Hideyo = Y / 1000;
int x = 0;
int y = 0;
int z = 0;
for (int i = 0;i<=Yukichi;i++)
{
for (int j =0;j<=Ichiyo;j++)
{
for (int k =0;k<=Hideyo;k++)
{
sum = 10000 * i + 5000 * j + 1000 * k;
if (sum == Y && i+j+k < N)
{
x = i;
y = j;
z = k;
//Console.WriteLine(i + " " + j + " " + k);
test = true;
}
}
}
}
if (test == true)
{
Console.WriteLine(x + " " + y + " " + z);
}
if (test == false)
{
Console.WriteLine("-1 -1 -1");
}
}*/
/*static void Main()
{
string[] aa = Console.ReadLine().Split();
int N = int.Parse(aa[0]);
int Y = int.Parse(aa[1]);
int X = 0;
int Z = 0;
int b = 0;
int d = 0;
X = Y / 10000;
var a = Y - (X*10000);
if (a != 0 || Y < 10000)
{
b = a / 5000;
var cc = a - (b * 5000);
if (cc != 0 || a < 5000)
{
d = cc / 1000;
var gg = cc - (d * 1000);
if (gg != 0 || cc<1000)
{
Console.WriteLine("-1 -1 -1");
}
else if (X + b + d <= N)
{
Console.WriteLine(X + " " + b + " " + d);
}
else if (X + b + d > N)
{
Console.WriteLine("-1 -1 -1");
}
}
else if (X + b <= N)
{
Console.WriteLine(X +" "+ b +" "+"0");
}
else if (X + b > N)
{
Console.WriteLine("-1 -1 -1");
}
}
else if (X <= N)
{
Console.WriteLine(X +" "+0+" "+0);
}
else if (X>N)
{
Console.WriteLine("-1 -1 -1");
}
}*/
/*static void Main()
{
string s = Console.ReadLine();
var Ans = s.Replace("eraser", "").Replace("dreamer",
"").Replace("dreamer", "").Replace("erase", "").ToString(); if (Ans == null)
Console.WriteLine("YES"); else Console.WriteLine("NO");*/
// List<string> str = new List<string>(); || s.Substring(5, 1) == ""
// string NN = new string(s); || s.Substring(5,1) == ""
/*while (true) {
while (true)
{
if (s.StartsWith("dream") && (s.Substring(5,2) != "er" ))
{
count++;
var f = s.Remove(0, 5);
s = f;
break;
}
if (s.StartsWith("dreamer"))
{
var n = s.Remove(0, 7);
s = n;
break;
}
if (s.StartsWith("erase") || (s.Substring(5,1) != "r" ))
{
count2++;
var f1 = s.Remove(0, 5);
s = f1;
break;
}
if (s.StartsWith("eraser"))
{
var f2 = s.Remove(0, 6);
s = f2;
break;
}
else
{
tt = true;
break;
}
}
if (s.Length == 0)
{
Console.WriteLine("YES");
break;
}
if (tt)
{
Console.WriteLine("NO");
break;
}
}*/
// Console.WriteLine(count+","+count2);
//}
// 86C
/*static void Main()
{
/*string aa = Console.ReadLine();
List<int[]> nn = new List<int[]>();
for (int i = 0;i<aa.Length;i++)
{
string[] str = Console.ReadLine().Split();
int[] intstr = str.Select(int.Parse).ToArray();
nn.Add(intstr);
}
var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
var num = a1[0];
var list = new List<int[]>(num);
for (int i=0;i<num;i++)
{
}
}*/
/*static void Main(string[] args)
{
var input = Console.ReadLine().Split(' ');
var array = input.Select(int.Parse).ToArray();
int num = array[0] * 100 + array[1] * 10 + array[2] * 1;
if (num % 4 == 0)
{
Console.WriteLine("YES");
}
else
{
Console.WriteLine("NO");
}
}*/
/*static void Main()
{
var input = Console.ReadLine();
var a = Console.ReadLine();
int N = int.Parse(input);
int A = int.Parse(a);
bool flag = false;
for (int i = 0;i <= A;i++ )
{
var Ans = N - i;
if (Ans % 500 == 0)
{
Console.WriteLine("Yes");
flag = true;
break;
}
}
if (flag == false)
{
Console.WriteLine("No");
}
}*/
/*static void Main()
{
var a = Console.ReadLine().Split();
double[] integer = a.Select(double.Parse).ToArray();
double ans = (integer[0] + integer[1]) / 2;
Console.WriteLine(Math.Ceiling(ans));
}*/
/*static void Main()
{
int count = 0;
string str = Console.ReadLine();
//var cross = str.Select(n => n != 'ร');
//var circle = str.Select(n => n != 'o');
//Console.WriteLine(cross);
//Console.WriteLine(circle);
/*Console.WriteLine(str.Length);
while (true)
{
Match match1 = Regex.Match(str, "o");
if (match1 != null)
{
count++;
}
str = str.Substring(match1.Index+1, str.Length);
if (match1.Index == str.Length)
{
break;
}
}
var Ans = 700 + count * 100;
Console.WriteLine(Ans);*/
// Console.WriteLine(match.Value);
/*or (int i =0;i<str.Length;i++)
{
if (Regex.Match(str[i], "o"))
{
}
}
count = str.Length - str.Replace("o", "").Length;
var Ans = 700 + count * 100;
Console.WriteLine(Ans);
}*/
/*static void Main()
{
var str = Console.ReadLine();
var Ans = str.Replace("2017","2018");
Console.WriteLine(Ans);
}*/
/*static void Main()
{
var str = Console.ReadLine();
//str.Substring(0, 1) +
Console.WriteLine(str.Substring(0, 1) + (str.Length-2) +
str.Substring(str.Length-1));
}*/
// 82B
/*static void Main()
{
var s = Console.ReadLine();
var t = Console.ReadLine();
char[] S = s.ToArray();
char[] T = t.ToArray();
Array.Sort(S);
Array.Sort(T);Array.Reverse(T);
string ss = new string(S);
string ts = new string(T);
if (ss.CompareTo(ts) < 0)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}*/
// sใซ้ขใใฆใฝใผใ
/*for (int i = 0; i < s.Length; i++)
{
}*/
// var hoge = s.OrderByDescending((x) => x.Value);
/*List<int> array = new List<int>();
int[] rank = new int[s.Length];
for (int i = 0; i < s.Length; i++)
{
rank[i] = 0;
}
for (int i = 0; i < s.Length; i++)
{
for (int j = 0; j < s.Length; j++)
{
if (s[i] > s[j])
{
rank[i]++;
}
}
}
for (int i=0;i<s.Length;i++)
{
for (int j =0;j<s.Length;j++)
{
if (i == rank[j])
{
array.Add(s[i]);
}
}
}
for (int i = 0; i < s.Length; i++)
{
Console.Write(array[i]);
}
}*/
/*static void Main()
{
int count;
int temp = 0;
var N = int.Parse(Console.ReadLine());
List<int> aa = new List<int>();
for (int i = 1; i <= N; i++)
{
count = 0;
temp = i;
while (true)
{
var Ans = temp / 2;
var Ans2 = temp % 2;
if (Ans2 == 0)
{
count++;
temp = Ans;
}
else
{
break;
}
}
aa.Add(count);
}
//Program program = new Program();
//program.Max(aa, temp);
var max = aa.IndexOf(aa.Max());
Console.WriteLine(max+1);
}
public void Max(List<int> array,int num)
{
var Ans3 = array.Max();
}*/
/*static void Main()
{
List<int> array = new List<int>();
var N = Console.ReadLine();
int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
for (int i = 0;i<A.Length;i++)
{
for (int j = 0; j< A.Length; j++)
{
var ans = A[i] - A[j];
if (ans < 0)
{
ans = Math.Abs(ans);
}
//Console.Write(ans);
array.Add(ans);
}
//Console.WriteLine();
}
Console.WriteLine(array.Max());
}*/
/*static void Main()
{
var N = Console.ReadLine();
int[] temperture = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] height = Console.ReadLine().Split().Select(int.Parse).ToArray();
int T = temperture[0];
int A = temperture[1];
List<double> aa = new List<double>();
List<double> bb = new List<double>();
for (int i = 0;i<height.Length;i++)
{
var temp = T - height[i] * 0.006;
aa.Add(temp);
}
for (int i =0;i<height.Length;i++)
{
var temp = A - aa[i];
if (temp < 0)
{
temp = Math.Abs(temp);
}
bb.Add(temp);
}
Console.WriteLine(bb.IndexOf(bb.Min())+1);
}*/
/*static void Main()
{
string a = Console.ReadLine();
char[] charArray = a.ToArray();
List<char> aa = new List<char>();
for (int i = 0;i<charArray.Length;i++)
{
if ((i+1)%2 == 1)
{
aa.Add(charArray[i]);
}
}
var str = string.Join("",aa);
Console.WriteLine(str);
}*/
// 053B
/*static void Main()
{
var str = Console.ReadLine();
var start = str.IndexOf("A");
var goal = str.IndexOf("Z",start);
string temp = new string(str.Substring(goal).ToArray());
int goalpoint = 0;
List<int> kk = new List<int>();
while (true)
{
if (temp.Contains("Z"))
{
goalpoint = temp.IndexOf("Z") +1;
temp = temp.Replace("Z", "");
}
if (temp.Contains("Z") == false)
{
break;
}
if(temp.Contains("Z"))
{
Console.WriteLine();
}
}
for (int i = 0;i<temp.Length;i++)
{
if (temp[i] == 'Z')
{
goalpoint = i;
}
}
var ans = str.Substring(start, goal-start).Length + 1 + goalpoint;
Console.WriteLine(ans);
}*/
// 095B
/*static void Main()
{
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = a[0];
int X = a[1];
List<int> listarray = new List<int>();
int Ans = 0;
for (int i =0;i < N;i++)
{
var temp = Console.ReadLine();
int temp1 = int.Parse(temp);
listarray.Add(temp1);
}
for (int i =0;i< N;i++)
{
X = X - listarray[i];
if (X >= 0)
{
Ans++;
}
}
if (X > 0)
{
while (true)
{
X = X - listarray.Min();
if (X < 0)
{
break;
}
Ans++;
}
}
Console.WriteLine(Ans);
}*/
// 105B
/*static void Main()
{
int dunats = 7;
int cake = 4;
int sum = 0;
bool flag = false;
int N = int.Parse(Console.ReadLine());
if (N > 3)
{
for (int i = 0; i <= N / cake; i++)
{
for (int j=0; j<=N/dunats;j++)
{
sum = dunats * j + cake * i;
if (sum == N) {
flag = true;
}
if (flag == true)
{
break;
}
}
if (flag == true)
{
break;
}
}
}
if (flag == true) { Console.WriteLine("Yes"); }
else { Console.WriteLine("No"); }
}*/
// 004A
/*static void Main()
{
List<double> Ans = new List<double>();
List<int[]> array = new List<int[]>();
int N = int.Parse(Console.ReadLine());
for (int i = 0; i < N; i++)
{
int[] aa = Console.ReadLine().Split().Select(int.Parse).ToArray();
array.Add(aa);
}
for (int i=0;i<N;i++)
{
for (int j = 0;j<N;j++)
{
var X = array[i][0] - array[j][0];
var Y = array[i][1] - array[j][1];
var resultX = Math.Pow(X, 2);
var resultY = Math.Pow(Y, 2);
var ans = Math.Sqrt(resultX + resultY);
Ans.Add(ans);
}
}
var finalresult = Ans.Max();
Console.WriteLine(finalresult);
}*/
// 51B
/*static void Main()
{
int count = 0;
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int K = input[0];
int S = input[1];
for (int x =0;x<= K;x++)
{
for (int y = 0; y <= K; y++)
{
var z = S - x - y;
if ( 0 <= z && z <= K)
{
count++;
}
}
}
Console.WriteLine(count);
}*/
// 80B
/*static void Main()
{
int Ans = 0;
string x = Console.ReadLine();
int X = int.Parse(x);
for (int i =0;i<x.Length;i++)
{
var temp = Convert.ToInt32(x[i].ToString());
Ans += temp;
}
if (X % Ans == 0)
{
Console.WriteLine("Yes");
}
else
{
Console.WriteLine("No");
}
}*/
// 90B
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int A = input[0];
int B = input[1];
int aaa = 0;
int count = 1;
int ko = 0;
string ans ="";
StringBuilder sb = new StringBuilder();
while(true)
{
string X = A.ToString();
count = 1;
ans = "";
//Console.WriteLine(X[X.Length - count]);
while (true)
{
//sb = null;
sb.Append(X[X.Length - count]);
if (X.Length - count == 0)
{
ans = sb.ToString();
break;
}
count++;
}
sb.Remove(0,X.Length);
aaa = int.Parse(ans);
//Console.WriteLine(aaa);
if (A == aaa)
{
ko++;
}
if (A == B)
{
break;
}
A++;
}
Console.WriteLine(ko);
}*/
// 25A
/*static void Main()
{
int ansA = 0;
int ansB = 0;
int N = int.Parse(Console.ReadLine());
List<int> Ans = new List<int>();
for (int A = 1;A<N;A++)
{
int B = N - A;
List<int> la = new List<int>();
List<int> lb = new List<int>();
ansA = 0;
ansB = 0;
string a = A.ToString();
string b = B.ToString();
for (int i =0;i<a.Length;i++)
{
char ca = a[i];
int intca = Convert.ToInt32(ca.ToString());
la.Add(intca);
}
for (int i=0;i<b.Length;i++)
{
char cb = b[i];
int intcb = Convert.ToInt32(cb.ToString());
lb.Add(intcb);
}
foreach(int n in la)
{
ansA += n;
}
foreach (int n in lb)
{
ansB += n;
}
Ans.Add(ansA + ansB);
}
Console.WriteLine(Ans.Min());
}*/
// 67B
/*static void Main()
{
int Ans = 0;
List<int> array = new List<int>();
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int K = input[1];
int[] length = Console.ReadLine().Split().Select(int.Parse).ToArray();
//int[] newone = new int[length.Length];
Array.Sort(length);
Array.Reverse(length);
for (int i = 0;i<K;i++)
{
array.Add(length[i]);
Ans += length[i];
}
Console.WriteLine(Ans);
}*/
// 42B
/*static void Main()
{
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int L = input[1];
string[] str = new string[N];
for (int i=0;i<N;i++)
{
var a = Console.ReadLine();
str[i] = a;
}
StringComparer cmp = StringComparer.OrdinalIgnoreCase;
Array.Sort(str,cmp);
List<string> Ans = new List<string>();
for (int i = 0;i<N;i++)
{
Ans.Add(string.Concat(str[i]));
}
StringBuilder sb = new StringBuilder();
for (int i = 0;i<N;i++)
{
sb.Append(Ans[i]);
sb.Append(string.Concat(str[i]));
}
Console.WriteLine(sb);
}*/
// 27A
static void Main() {
int Ans = 0;
int count = 0;
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int x = input[1];
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
Array.Sort(a);
for (int i = 0; i < N; i++) {
x -= a[i];
if (x >= 0) {
count++;
}
if (x < 0) {
break;
}
}
if (x > 0) {
count--;
}
Console.WriteLine(count);
}
}
}
|
[["-", 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, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 110], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 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], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 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], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 223, 0, 68], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 247
| 30
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var Nx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = Nx[0];
var x = Nx[1];
var aList = Console.ReadLine().Split(' ').Select(int.Parse);
var nokori = x;
var output = 0;
foreach (var a in aList.OrderBy(a => a)) {
nokori -= a;
if (nokori >= 0) {
output++;
}
}
if (nokori > 0) {
output--;
}
Console.WriteLine(output);
}
static int SumOfDigits(int x) {
var sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
}
}
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var Nx = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var N = Nx[0];
var x = Nx[1];
var aList = Console.ReadLine().Split(' ').Select(int.Parse);
var nokori = x;
var output = 0;
foreach (var a in aList.OrderBy(a => a)) {
nokori -= a;
if (nokori >= 0) {
output++;
}
if (nokori <= 0) {
break;
}
}
if (nokori > 0) {
output--;
}
Console.WriteLine(output);
}
static int SumOfDigits(int x) {
var sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
}
}
|
[["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 0, 210, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 195, 8, 196, 0, 210, 8, 196, 0, 46]]
| 8
| 187
| 10
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC122_20200406D.Input;
namespace ABC122_20200406D {
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, m;
Cin(out n, out m);
long max = 0;
long l = 1;
while (l * l <= m) {
if (m % l == 0) {
if (m / l >= n)
max = Math.Max(max, l);
if (m / (m / l) >= n)
max = Math.Max(max, l);
}
l++;
}
Console.WriteLine(max);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC122_20200406D.Input;
namespace ABC122_20200406D {
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, m;
Cin(out n, out m);
long max = 0;
long l = 1;
while (l * l <= m) {
if (m % l == 0) {
if (m / l >= n)
max = Math.Max(max, l);
long d = m / l;
if (m / d >= n)
max = Math.Max(max, d);
}
l++;
}
Console.WriteLine(max);
}
}
}
|
[["-", 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, 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, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["-", 15, 16, 31, 16, 12, 23, 0, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 12, 23, 0, 25], ["+", 64, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["-", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 1,467
| 13
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
///ใใใใ
static void Solve() {
int N;
int M;
Multi(out N, out M);
var ans = 1;
for (int i = 1; i < Math.Sqrt(M); i++) {
if (M % i == 0) {
if (M / N >= i) {
ans = i;
} else {
ans = M / i;
break;
}
}
}
Console.WriteLine(ans);
}
}
//ๆกๅผตใกใฝใใ
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public void WriteObjects<T>(IList<T> values) {
var num = values.Count;
for (int i = 0; i < num; i++) {
Console.Write(values[i]);
if (i < num - 1) {
Console.Write(" ");
}
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
///ใใใใ
static void Solve() {
int N;
int M;
Multi(out N, out M);
var ans = 1;
for (int i = 1; i <= Math.Min(Math.Sqrt(M), M / N); i++) {
if (M % i == 0) {
if (i >= N) {
ans = M / i;
break;
} else {
ans = i;
}
}
}
Console.WriteLine(ans);
}
}
//ๆกๅผตใกใฝใใ
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public void WriteObjects<T>(IList<T> values) {
var num = values.Count;
for (int i = 0; i < num; i++) {
Console.Write(values[i]);
if (i < num - 1) {
Console.Write(" ");
}
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 21], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["-", 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, 20], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 12, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 64, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 64, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 75, 196, 0, 1, 0, 11, 12, 16, 17, 85], ["-", 64, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 64, 196, 0, 57, 75, 196, 0, 93, 0, 94]]
| 8
| 1,178
| 25
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
///ใใใใ
static void Solve() {
int N;
int M;
Multi(out N, out M);
var ans = 1;
var limit = Math.Max((int)Math.Sqrt(M), 100000);
for (int i = N; i <= limit; i++) {
if (M % i == 0) {
ans = M / i;
break;
}
}
Console.WriteLine(ans);
}
}
//ๆกๅผตใกใฝใใ
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public void WriteObjects<T>(IList<T> values) {
var num = values.Count;
for (int i = 0; i < num; i++) {
Console.Write(values[i]);
if (i < num - 1) {
Console.Write(" ");
}
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
partial class Program {
static long mod = 1000000007;
static void Main() {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
Solve();
Console.Out.Flush();
Console.ReadKey();
}
///ใใใใ
static void Solve() {
int N;
int M;
Multi(out N, out M);
var ans = 1;
for (int i = M / N; i > 0; i--) {
if (M % i == 0) {
ans = i;
break;
}
}
Console.WriteLine(ans);
}
}
//ๆกๅผตใกใฝใใ
public static class Ex {
public static List<string> FastSort(this List<string> s) {
s.Sort(StringComparer.Ordinal);
return s.ToList();
}
public static string yesno(this bool b) { return b ? "yes" : "no"; }
public static string YesNo(this bool b) { return b ? "Yes" : "No"; }
public static string YESNO(this bool b) { return b ? "YES" : "NO"; }
}
partial class Program {
static public string GetStr() { return Console.ReadLine().Trim(); }
static public char GetChar() { return Console.ReadLine().Trim()[0]; }
static public int GetInt() { return int.Parse(Console.ReadLine().Trim()); }
static public long GetLong() { return long.Parse(Console.ReadLine().Trim()); }
static public double GetDouble() {
return double.Parse(Console.ReadLine().Trim());
}
static public string[] GetStrArray() {
return Console.ReadLine().Trim().Split(' ');
}
static public int[] GetIntArray() {
return Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
}
static public char[] GetCharArray() {
return Console.ReadLine().Trim().Split(' ').Select(char.Parse).ToArray();
}
static public double[] GetDoubleArray() {
return Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();
}
static public void WriteObjects<T>(IList<T> values) {
var num = values.Count;
for (int i = 0; i < num; i++) {
Console.Write(values[i]);
if (i < num - 1) {
Console.Write(" ");
}
}
Console.WriteLine();
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
static void Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
}
static void Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d,
out X e) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
d = cv<W>(ar[3]);
e = cv<X>(ar[4]);
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 0, 131], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["-", 0, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["-", 0, 28, 0, 74, 51, 213, 63, 214, 205, 22], ["-", 0, 28, 0, 74, 51, 213, 63, 214, 0, 131], ["-", 0, 28, 0, 74, 51, 213, 63, 214, 141, 22], ["-", 0, 28, 0, 74, 51, 213, 3, 4, 0, 24], ["-", 0, 74, 51, 213, 3, 4, 0, 28, 0, 22], ["-", 0, 28, 0, 74, 51, 213, 3, 4, 0, 25], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 21], ["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 7, 26, 223, 0, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 85]]
| 8
| 1,176
| 30
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder {
public class ABC {
static readonly int mod = 1000000007; // 10^9+7
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
// int n = int.Parse(Console.ReadLine());
// string s = Console.ReadLine();
int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
// long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
int n = vs[0];
int m = vs[1];
int ans = 0;
for (int i = (int)Math.Sqrt(m); i > 0; i--) {
if (m % i == 0) {
if (m / i >= n) {
ans = i;
break;
}
}
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder {
public class ABC {
static readonly int mod = 1000000007; // 10^9+7
static void Main(string[] args) {
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
// int n = int.Parse(Console.ReadLine());
// string s = Console.ReadLine();
int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
// long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
int n = vs[0];
int m = vs[1];
int ans = 0;
for (int i = m / n; i > 0; i--) {
if (m % i == 0) {
// System.Diagnostics.Debug.WriteLine($"{m} / {i} = {m / i} >= {n}");
if (m / i >= n) {
ans = i;
break;
}
}
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
}
|
[["-", 10, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["-", 10, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["-", 10, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 0, 131], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 141, 22], ["-", 0, 212, 0, 74, 51, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 74, 51, 213, 3, 4, 0, 25], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
| 8
| 195
| 10
|
using System;
namespace ABC112_D___Partition {
class Program {
static void Main(string[] args) { Console.WriteLine(solver()); }
static int solver() {
var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = NM[0];
var M = NM[1];
for (int i = 2; i <= M / 2; i++) {
if (M % i == 0 && i >= N)
return M / i;
}
return 1;
}
}
}
|
using System;
namespace ABC112_D___Partition {
class Program {
static void Main(string[] args) { Console.WriteLine(solver()); }
static int solver() {
var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var N = NM[0];
var M = NM[1];
if (N == 1)
return M;
for (int i = 2; i <= M / 2; i++) {
if (M % i == 0 && i >= N)
return M / i;
}
return 1;
}
}
}
|
[["+", 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
| 117
| 6
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace ABC112D {
class Program {
static void Solve(Input input) {
var n = input.NextInt();
var m = input.NextInt();
// ๅ
จใฆใฎ่ฆ็ด ใไธใคใฎๅ
ฌ็ดๆฐใๆใคๅฟ
่ฆใใใใ
// ใใฎๅคใฏm/nไปฅไธใจใชใ
var d = m / n;
// ใใคdใฏmใฎ็ดๆฐใงใใ
var ds = divs(m).OrderByDescending(x => x).ToArray();
Console.WriteLine(ds.SkipWhile(x => x > d).FirstOrDefault());
}
static IEnumerable<int> divs(int n) {
for (int i = 1; i * i <= n; i++) {
if (n % i == 0)
yield return i;
}
if (n != 1)
yield return n;
}
#region Main
public static void Main(string[] args) {
// ๅบๅใๅฐใชใใจใใฏใใใใปใใใใๆนใๆ้ใใใใใใฉ
// ใใฎๅ ดๅใฏๅบๅใใใใซใใใฏใซใชใฃใฆใใชใใฎใงใใพใ่ฏใใจใใ
var needsFlushOutput = true;
if (needsFlushOutput) {
// ็ดฐใใๅบๅใใชใใใใซใใ
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// ้ๅธธใฏๅผๆฐ็กใใงใใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
var input = new Input();
// ไปฎๆณ็ใซๆจๆบๅ
ฅๅใใปใใใใ
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
#endregion
#region Competitive Template
#pragma warning disable CS0414
static readonly int MOD = (int)1e9 + 7;
#pragma warning restore CS0414
class Input {
// ๅคใชๆน่กใณใผใใใใพใซๆททใใฃใฆใใใฎใงใไธๅฟใปใใฌใผใๆๅฎใใ
// ในใใผในๅ็ฌๆๅฎใฎๆนใใใกใใๆฉใ
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// ็นๅฎใฎใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// ๅ
้จqueueใซๅ
ฅๅใใใฎๅคใsplitใใฆๆ ผ็ดใใ
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// ๆฌกใฎstringใไธใค่ชญใฟ่พผใ
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// ๆๅฎๅๆฐqueueใซใใพใใพใงenqueueใ็ถใใ
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// nๅใฎ่ฆ็ด ใparseใใฆใใใใใใซoffsetใaddใใ้
ๅใ่ฟใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vใงfillใใใT[d1][d2]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vใงfillใใใT[d1][d2][d3]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace ABC112D {
class Program {
static void Solve(Input input) {
var n = input.NextInt();
var m = input.NextInt();
// ๅ
จใฆใฎ่ฆ็ด ใไธใคใฎๅ
ฌ็ดๆฐใๆใคๅฟ
่ฆใใใใ
// ใใฎๅคใฏm/nไปฅไธใจใชใ
var d = m / n;
// ใใคdใฏmใฎ็ดๆฐใงใใ
var ds = divs(m).OrderByDescending(x => x).ToArray();
Console.WriteLine(ds.SkipWhile(x => x > d).FirstOrDefault());
}
static IEnumerable<int> divs(int n) {
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
yield return i;
yield return n / i;
}
}
if (n != 1)
yield return n;
}
#region Main
public static void Main(string[] args) {
// ๅบๅใๅฐใชใใจใใฏใใใใปใใใใๆนใๆ้ใใใใใใฉ
// ใใฎๅ ดๅใฏๅบๅใใใใซใใใฏใซใชใฃใฆใใชใใฎใงใใพใ่ฏใใจใใ
var needsFlushOutput = true;
if (needsFlushOutput) {
// ็ดฐใใๅบๅใใชใใใใซใใ
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// ้ๅธธใฏๅผๆฐ็กใใงใใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
var input = new Input();
// ไปฎๆณ็ใซๆจๆบๅ
ฅๅใใปใใใใ
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
#endregion
#region Competitive Template
#pragma warning disable CS0414
static readonly int MOD = (int)1e9 + 7;
#pragma warning restore CS0414
class Input {
// ๅคใชๆน่กใณใผใใใใพใซๆททใใฃใฆใใใฎใงใไธๅฟใปใใฌใผใๆๅฎใใ
// ในใใผในๅ็ฌๆๅฎใฎๆนใใใกใใๆฉใ
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// ็นๅฎใฎใใกใคใซใใ่ชญใฟๅบใใใๅ ดๅใฏpathๆๅฎใใ
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// ๅ
ฅๅไบ็ด
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// ๅ
้จqueueใซๅ
ฅๅใใใฎๅคใsplitใใฆๆ ผ็ดใใ
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// ๆฌกใฎstringใไธใค่ชญใฟ่พผใ
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// ๆๅฎๅๆฐqueueใซใใพใใพใงenqueueใ็ถใใ
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// nๅใฎ่ฆ็ด ใparseใใฆใใใใใใซoffsetใaddใใ้
ๅใ่ฟใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vใงfillใใใT[d1][d2]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vใงfillใใใT[d1][d2][d3]้
ๅใไฝๆใใ
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 285, 0, 286], ["+", 8, 196, 0, 57, 64, 196, 0, 285, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 285, 0, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 285, 0, 35], ["+", 0, 57, 64, 196, 0, 285, 0, 16, 31, 22], ["+", 0, 57, 64, 196, 0, 285, 0, 16, 17, 85], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,248
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private const long INFINITY = 9223372036854775807;
public static void Main() {
int N = NextInt();
int M = NextInt();
List<int> memo = new List<int>();
int m = (int)Math.Sqrt(M);
for (int i = 1; i <= m; i++) {
if (M % i == 0)
memo.Add(i);
}
long ans = 1;
foreach (var i in memo) {
if (i * N <= M)
ans = i;
else
break;
}
Console.WriteLine(ans);
}
}
public class Input {
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();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Prog {
private const int INF = 1000000007;
private const long INFINITY = 9223372036854775807;
public static void Main() {
long N = NextInt();
long M = NextInt();
List<int> memo = new List<int>();
int m = (int)Math.Sqrt(M);
for (int i = 1; i <= m; i++) {
if (M % i == 0)
memo.Add(i);
}
long ans = 1;
foreach (var i in memo) {
// Console.WriteLine(i + " : " + (M/i));
if (i * N <= M)
ans = Math.Max(i, ans);
if ((M / i) * N <= M)
ans = Math.Max(M / i, ans);
// Console.WriteLine(ans);
}
Console.WriteLine(ans);
}
}
public class Input {
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();
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 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], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 1, 0, 11, 12, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 210, 8, 196, 0, 57, 0, 95], ["-", 0, 210, 8, 196, 0, 57, 75, 93, 0, 94], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 31, 22], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 85], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 0, 210, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 8, 196, 0, 210, 8, 196, 0, 57, 0, 25], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 440
| 37
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program {
public static void Main() {
var s = Console.ReadLine().Split(' ');
var N = int.Parse(s[0]);
var M = int.Parse(s[1]);
for (int i = N; i > 0; i--) {
if (M % i == 0) {
Console.WriteLine(i);
break;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
class Program {
public static void Main() {
var s = Console.ReadLine().Split(' ');
var N = int.Parse(s[0]);
var M = int.Parse(s[1]);
int l = M / N;
for (int i = l; i > 0; i--) {
if (M % i == 0) {
Console.WriteLine(i);
break;
}
}
}
}
|
[["+", 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, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 22]]
| 8
| 109
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Numerics;
class Program {
static void Main(string[] args) {
label:
var sp = ReadLine().Split();
int n = Parse(sp[0]);
int m = Parse(sp[1]);
int max = m / n;
WriteLine(Yakusuu(m).Where(i => i <= max).Max());
// goto label;
}
static List<int> Yakusuu(int num) {
int sq = (int)Ceiling(Sqrt(num));
int sqsq = (int)Ceiling(Sqrt(sq));
var gousei = new bool[sq + 1];
for (int i = 2; i <= sqsq; ++i) {
if (gousei[i])
continue;
for (int j = i * 2; j < gousei.Length; j += i) {
gousei[j] = true;
}
}
var insuu = new List<List<int>>();
for (int i = 2; i < gousei.Length; ++i) {
if (!gousei[i]) {
if (num % i == 0) {
var list = new List<int>() { 1, i };
insuu.Add(list);
int j = i * i;
for (; num % j == 0; j *= i) {
list.Add(j);
}
num /= (j / i);
}
if (num < i)
break;
}
}
if (1 < num) {
insuu.Add(new List<int>() { 1, num });
}
var result = Get(insuu, 0).ToList();
return result;
}
static IEnumerable<int> Get(List<List<int>> lislis, int i) {
foreach (int n in lislis[i]) {
if (i == lislis.Count - 1) {
yield return n;
} else {
foreach (var next in Get(lislis, i + 1)) {
yield return n * next;
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;
using static System.Math;
using System.Numerics;
class Program {
static void Main(string[] args) {
label:
var sp = ReadLine().Split();
int n = Parse(sp[0]);
int m = Parse(sp[1]);
int max = m / n;
WriteLine(Yakusuu(m).Where(i => i <= max).Max());
// goto label;
}
static List<int> Yakusuu(int num) {
if (num == 1)
return new List<int>() { 1 };
int sq = (int)Ceiling(Sqrt(num));
int sqsq = (int)Ceiling(Sqrt(sq));
var gousei = new bool[sq + 1];
for (int i = 2; i <= sqsq; ++i) {
if (gousei[i])
continue;
for (int j = i * 2; j < gousei.Length; j += i) {
gousei[j] = true;
}
}
var insuu = new List<List<int>>();
for (int i = 2; i < gousei.Length; ++i) {
if (!gousei[i]) {
if (num % i == 0) {
var list = new List<int>() { 1, i };
insuu.Add(list);
int j = i * i;
for (; num % j == 0; j *= i) {
list.Add(j);
}
num /= (j / i);
}
if (num < i)
break;
}
}
if (1 < num) {
insuu.Add(new List<int>() { 1, num });
}
var result = Get(insuu, 0).ToList();
return result;
}
static IEnumerable<int> Get(List<List<int>> lislis, int i) {
foreach (int n in lislis[i]) {
if (i == lislis.Count - 1) {
yield return n;
} else {
foreach (var next in Get(lislis, i + 1)) {
yield return n * next;
}
}
}
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 37, 0, 230, 0, 228], ["+", 0, 57, 64, 37, 0, 230, 39, 236, 141, 22], ["+", 64, 37, 0, 230, 39, 236, 237, 238, 0, 18], ["+", 64, 37, 0, 230, 39, 236, 237, 238, 0, 199], ["+", 64, 37, 0, 230, 39, 236, 237, 238, 0, 47], ["+", 0, 57, 64, 37, 0, 230, 3, 4, 0, 24], ["+", 0, 57, 64, 37, 0, 230, 3, 4, 0, 25], ["+", 0, 57, 64, 37, 0, 230, 10, 229, 0, 45], ["+", 0, 57, 64, 37, 0, 230, 10, 229, 0, 203], ["+", 0, 57, 64, 37, 0, 230, 10, 229, 0, 46], ["+", 0, 195, 8, 196, 0, 57, 64, 37, 0, 35]]
| 8
| 458
| 18
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.ABC_112 {
class D {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
long[] nm = ReadLongs();
long n = nm[0];
long m = nm[1];
if (n == 1) {
Console.WriteLine(m);
return;
}
long max = (long)Math.Sqrt(m);
for (long i = max; i >= 1; i--) {
if (m % i == 0 && i <= m / n) {
Console.WriteLine(i);
return;
}
}
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
namespace AtTest.ABC_112 {
class D {
static void Main(string[] args) {
Method(args);
Console.ReadLine();
}
static void Method(string[] args) {
long[] nm = ReadLongs();
long n = nm[0];
long m = nm[1];
if (n == 1) {
Console.WriteLine(m);
return;
}
long max = m / n;
for (long i = max; i >= 1; i--) {
if (m % i == 0) {
Console.WriteLine(i);
return;
}
}
}
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 205, 22], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 0, 131], ["-", 0, 212, 0, 74, 51, 213, 63, 214, 141, 22], ["-", 0, 212, 0, 74, 51, 213, 3, 4, 0, 24], ["-", 0, 212, 0, 74, 51, 213, 3, 4, 0, 25], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 17, 85], ["-", 0, 57, 15, 16, 12, 16, 12, 16, 12, 22]]
| 8
| 307
| 16
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC112.D {
class Program {
static void Main() {
var sc = new Scanner();
var n = sc.Nextint();
var m = sc.Nextint();
var quotient = m / n;
var remainder = m % n;
var maxGcd = 0;
for (int i = 1; i * i <= m; i++) {
quotient = m / i;
remainder = m % i;
if (remainder == 0) {
quotient = i >= n ? quotient : i;
maxGcd = Math.Max(maxGcd, quotient);
}
}
Console.WriteLine(maxGcd);
}
}
class Scanner {
string[] s;
long i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int Nextint() { return int.Parse(Next()); }
public int[] Arrayint(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Nextint() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (long i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(long N, double add = 0) {
double[] Array = new double[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
public decimal NextDecimal() { return decimal.Parse(Next()); }
public decimal[] ArrayDecimal(long N, decimal add = 0) {
decimal[] Array = new decimal[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDecimal();
}
return Array;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC112.D {
class Program {
static void Main() {
var sc = new Scanner();
var n = sc.Nextint();
var m = sc.Nextint();
var maxGcd = 0;
for (int i = 1; i * i <= m; i++) {
var quotient = m / i;
var remainder = m % i;
if (remainder == 0) {
if (i < n) {
if (quotient >= n)
quotient = i;
else
continue;
}
maxGcd = Math.Max(maxGcd, quotient);
}
}
Console.WriteLine(maxGcd);
}
}
class Scanner {
string[] s;
long i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int Nextint() { return int.Parse(Next()); }
public int[] Arrayint(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Nextint() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (long i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(long N, double add = 0) {
double[] Array = new double[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
public decimal NextDecimal() { return decimal.Parse(Next()); }
public decimal[] ArrayDecimal(long N, decimal add = 0) {
decimal[] Array = new decimal[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDecimal();
}
return Array;
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 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, 17, 18], ["+", 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, 57, 64, 196, 0, 57, 0, 121], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 12, 41, 0, 101], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["-", 64, 196, 0, 1, 0, 11, 12, 41, 0, 102], ["+", 0, 57, 64, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 57, 64, 1, 0, 35], ["+", 64, 196, 0, 57, 64, 196, 0, 57, 0, 95], ["+", 0, 57, 64, 196, 0, 57, 75, 116, 0, 117], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 589
| 35
|
using System;
class hogehoge {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
int m = int.Parse(s[1]);
int r = 1;
for (int i = 1; i < 1000000000; i++) {
if (i * n > m)
break;
if (m % i == 0)
r = i;
}
Console.WriteLine(r);
}
}
|
using System;
class hogehoge {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int n = int.Parse(s[0]);
int m = int.Parse(s[1]);
int r = 1;
for (int i = 1; i < 1000000000; i++) {
if (n == 1) {
r = m;
break;
}
if (i * n > m)
break;
if (m % i == 0)
r = i;
}
Console.WriteLine(r);
}
}
|
[["+", 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, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24]]
| 8
| 112
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static PB10004.Algorithm.Util;
namespace PB10004.Algorithm {
class Template {
static void Main(string[] args) { new D().Solve(); }
}
class A {
public void Solve() {
var N = ReadInt();
if (N == 1) {
WriteLine("Hello World");
} else {
WriteLine(ReadInt() + ReadInt());
}
}
}
class B {
public void Solve() {
var array = ReadIntArray();
var N = array[0];
var T = array[1];
var min = 9999999;
var minT = 9999999;
for (int i = 0; i < N; i++) {
var line = ReadIntArray();
var c = line[0];
var t = line[1];
if (t <= T) {
min = Math.Min(c, min);
minT = Math.Min(t, minT);
}
}
if (minT > T)
WriteLine("TLE");
else
WriteLine(min);
}
}
class C {
List<Point> points = new List<Point>();
List<Point> tmp = new List<Point>();
public void Solve() {
var N = ReadInt();
for (int i = 0; i < N; i++) {
var array = ReadLongArray();
var p = new Point(array[0], array[1], array[2]);
if (array[2] > 0)
points.Add(p);
tmp.Add(p);
}
if (points.Count == 0)
points.AddRange(tmp);
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
long temp = -1;
bool isSuccess = true;
foreach (var item in points) {
var H = Math.Abs(i - item.X) + Math.Abs(j - item.Y) + item.H;
if (temp == -1)
temp = H;
else {
if (temp != H) {
if (item.H == 0 &&
temp - Math.Abs(i - item.X) - Math.Abs(j - item.Y) < 0)
temp = temp;
else
isSuccess = false;
}
}
}
if (isSuccess) {
WriteLine("{0} {1} {2}", i, j, temp);
return;
}
}
}
}
}
struct Point {
public Point(long x, long y, long h) {
X = x;
Y = y;
H = h;
}
public long X, Y, H;
}
class D {
public void Solve() {
var array = ReadLongArray();
var N = array[0];
var M = array[1];
long tmp = 1;
List<long> next = new List<long>();
for (long i = 1; i <= Math.Sqrt(M); i++) {
if (M % i == 0) {
var div = M / i;
next.Add(div);
if (div >= N) {
tmp = i;
} else {
WriteLine(tmp);
return;
}
}
}
foreach (var item in next.Reverse<long>()) {
var div = M / item;
next.Add(div);
if (div >= N) {
tmp = item;
} else {
WriteLine(tmp);
return;
}
}
}
}
public static class Util {
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static int ReadInt() { return int.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArray() {
return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static long ReadLong() { return long.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static long[] ReadLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
/// <summary>
/// ไธๅฎๅคใฎๆฐๅใ็ๆใใ
/// </summary>
/// <param name="value"></param>
/// <param name="length"></param>
/// <returns></returns>
public static IEnumerable<long> ConstSeq(long value, long length) {
for (int i = 0; i < length; i++) {
yield return value;
}
}
/// <summary>
/// int้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) {
int tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// long้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) {
long tmp = 0;
yield return tmp;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// ๆๅคงๅ
ฌ็ดๆฐใใฆใผใฏใชใใใฎไบ้คๆณใงๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
return b == 0 ? a : Gcd(b, a % b);
}
/// <summary>
/// ๆๅฐๅ
ฌๅๆฐใๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static PB10004.Algorithm.Util;
namespace PB10004.Algorithm {
class Template {
static void Main(string[] args) { new D().Solve(); }
}
class A {
public void Solve() {
var N = ReadInt();
if (N == 1) {
WriteLine("Hello World");
} else {
WriteLine(ReadInt() + ReadInt());
}
}
}
class B {
public void Solve() {
var array = ReadIntArray();
var N = array[0];
var T = array[1];
var min = 9999999;
var minT = 9999999;
for (int i = 0; i < N; i++) {
var line = ReadIntArray();
var c = line[0];
var t = line[1];
if (t <= T) {
min = Math.Min(c, min);
minT = Math.Min(t, minT);
}
}
if (minT > T)
WriteLine("TLE");
else
WriteLine(min);
}
}
class C {
List<Point> points = new List<Point>();
List<Point> tmp = new List<Point>();
public void Solve() {
var N = ReadInt();
for (int i = 0; i < N; i++) {
var array = ReadLongArray();
var p = new Point(array[0], array[1], array[2]);
if (array[2] > 0)
points.Add(p);
tmp.Add(p);
}
if (points.Count == 0)
points.AddRange(tmp);
for (int i = 0; i <= 100; i++) {
for (int j = 0; j <= 100; j++) {
long temp = -1;
bool isSuccess = true;
foreach (var item in points) {
var H = Math.Abs(i - item.X) + Math.Abs(j - item.Y) + item.H;
if (temp == -1)
temp = H;
else {
if (temp != H) {
if (item.H == 0 &&
temp - Math.Abs(i - item.X) - Math.Abs(j - item.Y) < 0)
temp = temp;
else
isSuccess = false;
}
}
}
if (isSuccess) {
WriteLine("{0} {1} {2}", i, j, temp);
return;
}
}
}
}
}
struct Point {
public Point(long x, long y, long h) {
X = x;
Y = y;
H = h;
}
public long X, Y, H;
}
class D {
public void Solve() {
var array = ReadLongArray();
var N = array[0];
var M = array[1];
long tmp = 1;
if (N == 1) {
WriteLine(M);
return;
}
List<long> next = new List<long>();
for (long i = 1; i <= Math.Sqrt(M); i++) {
if (M % i == 0) {
var div = M / i;
next.Add(div);
if (div >= N) {
tmp = i;
} else {
WriteLine(tmp);
return;
}
}
}
foreach (var item in next.Reverse<long>()) {
var div = M / item;
next.Add(div);
if (div >= N) {
tmp = item;
} else {
WriteLine(tmp);
return;
}
}
}
}
public static class Util {
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static int ReadInt() { return int.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใintๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static int[] ReadIntArray() {
return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใซใใผในใใ
/// </summary>
/// <returns></returns>
public static long ReadLong() { return long.Parse(ReadLine()); }
/// <summary>
/// ๆจๆบๅ
ฅๅใlongๅใฎ้
ๅใซใใ
/// </summary>
/// <returns></returns>
public static long[] ReadLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
/// <summary>
/// ไธๅฎๅคใฎๆฐๅใ็ๆใใ
/// </summary>
/// <param name="value"></param>
/// <param name="length"></param>
/// <returns></returns>
public static IEnumerable<long> ConstSeq(long value, long length) {
for (int i = 0; i < length; i++) {
yield return value;
}
}
/// <summary>
/// int้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) {
int tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// long้
ๅใฎ็ดฏ็ฉๅใๆฑใใ
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) {
long tmp = 0;
yield return tmp;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// ๆๅคงๅ
ฌ็ดๆฐใใฆใผใฏใชใใใฎไบ้คๆณใงๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
return b == 0 ? a : Gcd(b, a % b);
}
/// <summary>
/// ๆๅฐๅ
ฌๅๆฐใๆฑใใ
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 60], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 1,068
| 15
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
var l = new List<long>();
for (long i = 1; i * i <= M; i++) {
if (M % i != 0)
continue;
l.Add(i);
l.Add(M / i);
}
long max = 1;
foreach (var d in l) {
long n = M / d;
if (n >= N) {
max = d;
}
}
Console.WriteLine(max);
}
int N;
long M;
public Sol() {
var d = rla();
N = (int)d[0];
M = d[1];
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
var l = new List<long>();
for (long i = 1; i * i <= M; i++) {
if (M % i != 0)
continue;
l.Add(i);
l.Add(M / i);
}
long max = 1;
foreach (var d in l) {
long n = M / d;
if (n >= N) {
max = Math.Max(max, d);
}
}
Console.WriteLine(max);
}
int N;
long M;
public Sol() {
var d = rla();
N = (int)d[0];
M = d[1];
}
static String rs() { return Console.ReadLine(); }
static int ri() { return int.Parse(Console.ReadLine()); }
static long rl() { return long.Parse(Console.ReadLine()); }
static double rd() { return double.Parse(Console.ReadLine()); }
static String[] rsa(char sep = ' ') { return Console.ReadLine().Split(sep); }
static int[] ria(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e));
}
static long[] rla(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e));
}
static double[] rda(char sep = ' ') {
return Array.ConvertAll(Console.ReadLine().Split(sep),
e => double.Parse(e));
}
}
|
[["+", 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]]
| 8
| 413
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
// using System.Text;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
// using System.Numerics;
// using static System.Math;
// using pair = Pair<int, int>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //โโโโ
readonly int mod = 1000000007;
void chmax<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
void chmin<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }
void solve() {
long N = cin.nextint;
long M = cin.nextint;
long max = 1;
for (int i = 2; i * i <= M; i++) {
if (M % i != 0) {
continue;
}
if (N * i <= M) {
chmax(ref max, i);
}
var g = M / i;
if (N * g <= M) {
chmax(ref max, g);
}
}
WriteLine(max);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan {
get { return ReadLine().Split(); }
}
public int[] scanint {
get { return Array.ConvertAll(scan, int.Parse); }
}
public long[] scanlong {
get { return Array.ConvertAll(scan, long.Parse); }
}
public double[] scandouble {
get { return Array.ConvertAll(scan, double.Parse); }
}
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint {
get { return int.Parse(next); }
}
public long nextlong {
get { return long.Parse(next); }
}
public double nextdouble {
get { return double.Parse(next); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
// using System.Text;
// using System.Text.RegularExpressions;
// using System.Globalization;
// using System.Diagnostics;
using static System.Console;
// using System.Numerics;
// using static System.Math;
// using pair = Pair<int, int>;
class Program {
static void Main() {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
Scanner cin = new Scanner();
readonly int[] dd = { 0, 1, 0, -1, 0 }; //โโโโ
readonly int mod = 1000000007;
void chmax<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
void chmin<T>(ref T a, T b)
where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }
void solve() {
long N = cin.nextint;
long M = cin.nextint;
long max = 1;
if (N * M <= M) {
chmax(ref max, M);
}
for (int i = 2; i * i <= M; i++) {
if (M % i != 0) {
continue;
}
if (N * i <= M) {
chmax(ref max, i);
}
var g = M / i;
if (N * g <= M) {
chmax(ref max, g);
}
}
WriteLine(max);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string[] scan {
get { return ReadLine().Split(); }
}
public int[] scanint {
get { return Array.ConvertAll(scan, int.Parse); }
}
public long[] scanlong {
get { return Array.ConvertAll(scan, long.Parse); }
}
public double[] scandouble {
get { return Array.ConvertAll(scan, double.Parse); }
}
public string next {
get {
if (i < s.Length)
return s[i++];
string st = ReadLine();
while (st == "")
st = ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next;
}
}
public int nextint {
get { return int.Parse(next); }
}
public long nextlong {
get { return long.Parse(next); }
}
public double nextdouble {
get { return double.Parse(next); }
}
}
|
[["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 48], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["+", 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, 213, 63, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 275], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 21], ["+", 64, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["+", 0, 195, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 512
| 18
|
using System;
namespace AtCoder.ABC._112 {
class d {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var spl = line.Split(' ');
var N = int.Parse(spl[0]);
var M = int.Parse(spl[1]);
var O = (double)M / N;
for (var i = (int)Math.Floor(O); i > 1; --i) {
if (M % i == 0) {
Console.WriteLine(i);
return;
}
}
}
}
}
|
using System;
namespace AtCoder.ABC._112 {
class d {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var spl = line.Split(' ');
var N = int.Parse(spl[0]);
var M = int.Parse(spl[1]);
var O = (double)M / N;
for (var i = (int)Math.Floor(O); i > 1; --i) {
if (M % i == 0) {
Console.WriteLine(i);
return;
}
}
Console.WriteLine(1);
}
}
}
|
[["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 130
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;
class Program
{
static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const int M2 = 998244353;
const long LM = (long)1e18;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
const string dstring = "RDLU";
static void Main()
{
int k, n;
sc.Multi(out k, out n);
mymath.Mod = M2;
var comb = mymath.getcombs(n + k);
for (int i = 2; i <= k * 2; i++)
{
int c;
if (i <= k + 1) {
c = i / 2;
}
else {
c = i / 2 - (i - 1 - k);
}
long sum = 0;
if (i % 2 == 1) {
for (int j = 0; j <= c; j++)
{
if (n + k - c - c - 1 < 0 || n + k - c - c - 1 < n - c + j) continue;
sum = (sum + comb[c][j] % M2 * comb[n - c + k - c - 1][n - c + j] % M2 * mymath.pow(2, c - j)) % M2;
}
}
else {
--c;
for (int j = 0; j <= c; j++)
{
if (n + k - 1 - c - c - 1 < 0 || n + k - 1 - c - c - 1 < n - c + j) continue;
sum = (sum + comb[c][j] % M2 * comb[n - c + k - 1 - c - 1][n - c + j] % M2 * mymath.pow(2, c - j)) % M2;
}
for (int j = 0; j <= c; j++)
{
if (n + k - 2 - c - c - 1 < 0 || n + k - 2 - c - c - 1 < n - 1 - c + j) continue;
sum = (sum + comb[c][j] % M2 * comb[n - c + k - 2 - c - 1][n - 1 - c + j] % M2 * mymath.pow(2, c - j)) % M2;
}
}
Prt(sum);
}
sw.Flush();
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
public override string ToString() => v1 + " " + v2;
}
static class util
{
public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]);
public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2);
public static T sqr<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
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[] 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;
}
}
static class Operator<T>
{
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan
{
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => Console.ReadLine().Trim();
public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U>
{ T a; U b; Multi(out a, out b); return new pair<T, U>(a, b); }
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 []{' '}, System.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]); }
public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
{ var ar = 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]); f = cv<Y>(ar[5]); }
}
static class mymath
{
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2) return false;
for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++) p[i] = true;
for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long[n][];
for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
return ret;
}
public static double[][] dE(int n) {
var ret = new double[n][];
for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; }
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0) return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0) return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static int dot(int[] x, int[] y) {
int n = x.Length;
int ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
return ret;
}
public static double[] mul(double a, double[] x) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i];
return ret;
}
public static long[] mul(long a, long[] x) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod;
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static int[] mul(int[][] A, int[] x) {
int n = A.Length;
var ret = new int[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static double[][] mul(double a, double[][] A) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static long[][] mul(long a, long[][] A) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static int[][] mul(int[][] A, int[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new int[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static int[] add(int[] x, int[] y) {
int n = x.Length;
var ret = new int[n];
for (int i = 0; i < n; i++) ret[i] = x[i] + y[i];
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static double[] add(double[] x, double[] y) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static double[][] add(double[][] A, double[][] B) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod) return pow(a % Mod, b);
if (a == 0) return 0;
if (b == 0) return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0) return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) => pow(a, Mod - 2);
public static long gcd(long a, long b) {
while (b > 0) { var t = a % b; a = b; b = t; } return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a; x = 1; y = 0;
if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
return g;
}
public static long lcm(long a, long b) => a / gcd(a, b) * b;
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n) return 0;
if (n - r < r) r = n - r;
if (r == 0) return 1;
if (r == 1) return n;
if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }
}
}
long ret = 1;
for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long[n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;
using static util;
using P = pair<int, int>;
using Binary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.ParameterExpression,
System.Linq.Expressions.BinaryExpression>;
using Unary = System.Func<System.Linq.Expressions.ParameterExpression, System.Linq.Expressions.UnaryExpression>;
class Program
{
static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
static Scan sc = new Scan();
const int M = 1000000007;
const int M2 = 998244353;
const long LM = (long)1e18;
const double eps = 1e-11;
static readonly int[] dd = { 0, 1, 0, -1, 0 };
const string dstring = "RDLU";
static void Main()
{
int k, n;
sc.Multi(out k, out n);
mymath.Mod = M2;
var comb = mymath.getcombs(n + k);
for (int i = 2; i <= k * 2; i++)
{
int c;
if (i <= k + 1) {
c = i / 2;
}
else {
c = i / 2 - (i - 1 - k);
}
long sum = 0;
if (i % 2 == 1) {
for (int j = 0; j <= c; j++)
{
if (n + k - c - c - 1 < 0 || n + k - c - c - 1 < n - c + j || n - c + j < 0) continue;
sum = (sum + comb[c][j] % M2 * comb[n - c + k - c - 1][n - c + j] % M2 * mymath.pow(2, c - j)) % M2;
}
}
else {
--c;
for (int j = 0; j <= c; j++)
{
if (n + k - 1 - c - c - 1 < 0 || n + k - 1 - c - c - 1 < n - c + j || n - c + j < 0) continue;
sum = (sum + comb[c][j] % M2 * comb[n - c + k - 1 - c - 1][n - c + j] % M2 * mymath.pow(2, c - j)) % M2;
}
for (int j = 0; j <= c; j++)
{
if (n + k - 2 - c - c - 1 < 0 || n + k - 2 - c - c - 1 < n - 1 - c + j || n - 1 - c + j < 0) continue;
sum = (sum + comb[c][j] % M2 * comb[n - c + k - 2 - c - 1][n - 1 - c + j] % M2 * mymath.pow(2, c - j)) % M2;
}
}
Prt(sum);
}
sw.Flush();
}
static void DBG(string a) => Console.WriteLine(a);
static void DBG<T>(IEnumerable<T> a) => DBG(string.Join(" ", a));
static void DBG(params object[] a) => DBG(string.Join(" ", a));
static void Prt(string a) => sw.WriteLine(a);
static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a));
static void Prt(params object[] a) => Prt(string.Join(" ", a));
}
class pair<T, U> : IComparable<pair<T, U>> where T : IComparable<T> where U : IComparable<U>
{
public T v1;
public U v2;
public pair(T v1, U v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(pair<T, U> a) => v1.CompareTo(a.v1) != 0 ? v1.CompareTo(a.v1) : v2.CompareTo(a.v2);
public override string ToString() => v1 + " " + v2;
}
static class util
{
public static pair<T, T> make_pair<T>(this IList<T> l) where T : IComparable<T> => make_pair(l[0], l[1]);
public static pair<T, U> make_pair<T, U>(T v1, U v2) where T : IComparable<T> where U : IComparable<U> => new pair<T, U>(v1, v2);
public static T sqr<T>(T a) => Operator<T>.Multiply(a, a);
public static T Max<T>(params T[] a) => a.Max();
public static T Min<T>(params T[] a) => a.Min();
public static bool inside(int i, int j, int h, int w) => i >= 0 && i < h && j >= 0 && j < w;
public static void swap<T>(ref T a, ref T b) { var t = a; a = b; b = t; }
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[] 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;
}
}
static class Operator<T>
{
static readonly ParameterExpression x = Expression.Parameter(typeof(T), "x");
static readonly ParameterExpression y = Expression.Parameter(typeof(T), "y");
public static readonly Func<T, T, T> Add = Lambda(Expression.Add);
public static readonly Func<T, T, T> Subtract = Lambda(Expression.Subtract);
public static readonly Func<T, T, T> Multiply = Lambda(Expression.Multiply);
public static readonly Func<T, T, T> Divide = Lambda(Expression.Divide);
public static readonly Func<T, T> Plus = Lambda(Expression.UnaryPlus);
public static readonly Func<T, T> Negate = Lambda(Expression.Negate);
public static Func<T, T, T> Lambda(Binary op) => Expression.Lambda<Func<T, T, T>>(op(x, y), x, y).Compile();
public static Func<T, T> Lambda(Unary op) => Expression.Lambda<Func<T, T>>(op(x), x).Compile();
}
class Scan
{
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public string Str => Console.ReadLine().Trim();
public pair<T, U> Pair<T, U>() where T : IComparable<T> where U : IComparable<U>
{ T a; U b; Multi(out a, out b); return new pair<T, U>(a, b); }
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 []{' '}, System.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]); }
public void Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f)
{ var ar = 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]); f = cv<Y>(ar[5]); }
}
static class mymath
{
public static long Mod = 1000000007;
public static bool isprime(long a) {
if (a < 2) return false;
for (long i = 2; i * i <= a; i++) if (a % i == 0) return false;
return true;
}
public static bool[] sieve(int n) {
var p = new bool[n + 1];
for (int i = 2; i <= n; i++) p[i] = true;
for (int i = 2; i * i <= n; i++) if (p[i]) for (int j = i * i; j <= n; j += i) p[j] = false;
return p;
}
public static List<int> getprimes(int n) {
var prs = new List<int>();
var p = sieve(n);
for (int i = 2; i <= n; i++) if (p[i]) prs.Add(i);
return prs;
}
public static long[][] E(int n) {
var ret = new long[n][];
for (int i = 0; i < n; i++) { ret[i] = new long[n]; ret[i][i] = 1; }
return ret;
}
public static double[][] dE(int n) {
var ret = new double[n][];
for (int i = 0; i < n; i++) { ret[i] = new double[n]; ret[i][i] = 1; }
return ret;
}
public static long[][] pow(long[][] A, long n) {
if (n == 0) return E(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double[][] pow(double[][] A, long n) {
if (n == 0) return dE(A.Length);
var t = pow(A, n / 2);
if ((n & 1) == 0) return mul(t, t);
return mul(mul(t, t), A);
}
public static double dot(double[] x, double[] y) {
int n = x.Length;
double ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static long dot(long[] x, long[] y) {
int n = x.Length;
long ret = 0;
for (int i = 0; i < n; i++) ret = (ret + x[i] * y[i]) % Mod;
return ret;
}
public static int dot(int[] x, int[] y) {
int n = x.Length;
int ret = 0;
for (int i = 0; i < n; i++) ret += x[i] * y[i];
return ret;
}
public static T[][] trans<T>(T[][] A) {
int n = A[0].Length, m = A.Length;
var ret = new T[n][];
for (int i = 0; i < n; i++) { ret[i] = new T[m]; for (int j = 0; j < m; j++) ret[i][j] = A[j][i]; }
return ret;
}
public static double[] mul(double a, double[] x) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i];
return ret;
}
public static long[] mul(long a, long[] x) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = a * x[i] % Mod;
return ret;
}
public static double[] mul(double[][] A, double[] x) {
int n = A.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static long[] mul(long[][] A, long[] x) {
int n = A.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static int[] mul(int[][] A, int[] x) {
int n = A.Length;
var ret = new int[n];
for (int i = 0; i < n; i++) ret[i] = dot(x, A[i]);
return ret;
}
public static double[][] mul(double a, double[][] A) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static long[][] mul(long a, long[][] A) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(a, A[i]);
return ret;
}
public static double[][] mul(double[][] A, double[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[][] mul(long[][] A, long[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static int[][] mul(int[][] A, int[][] B) {
int n = A.Length;
var Bt = trans(B);
var ret = new int[n][];
for (int i = 0; i < n; i++) ret[i] = mul(Bt, A[i]);
return ret;
}
public static long[] add(long[] x, long[] y) {
int n = x.Length;
var ret = new long[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static int[] add(int[] x, int[] y) {
int n = x.Length;
var ret = new int[n];
for (int i = 0; i < n; i++) ret[i] = x[i] + y[i];
return ret;
}
public static long[][] add(long[][] A, long[][] B) {
int n = A.Length;
var ret = new long[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static double[] add(double[] x, double[] y) {
int n = x.Length;
var ret = new double[n];
for (int i = 0; i < n; i++) ret[i] = (x[i] + y[i]) % Mod;
return ret;
}
public static double[][] add(double[][] A, double[][] B) {
int n = A.Length;
var ret = new double[n][];
for (int i = 0; i < n; i++) ret[i] = add(A[i], B[i]);
return ret;
}
public static long pow(long a, long b) {
if (a >= Mod) return pow(a % Mod, b);
if (a == 0) return 0;
if (b == 0) return 1;
var t = pow(a, b / 2);
if ((b & 1) == 0) return t * t % Mod;
return t * t % Mod * a % Mod;
}
public static long inv(long a) => pow(a, Mod - 2);
public static long gcd(long a, long b) {
while (b > 0) { var t = a % b; a = b; b = t; } return a;
}
// a x + b y = gcd(a, b)
public static long extgcd(long a, long b, out long x, out long y) {
long g = a; x = 1; y = 0;
if (b > 0) { g = extgcd(b, a % b, out y, out x); y -= a / b * x; }
return g;
}
public static long lcm(long a, long b) => a / gcd(a, b) * b;
static long[] facts;
public static long[] setfacts(int n) {
facts = new long[n + 1];
facts[0] = 1;
for (int i = 0; i < n; i++) facts[i + 1] = facts[i] * (i + 1) % Mod;
return facts;
}
public static long comb(int n, int r) {
if (n < 0 || r < 0 || r > n) return 0;
if (n - r < r) r = n - r;
if (r == 0) return 1;
if (r == 1) return n;
if (facts != null && facts.Length > n) return facts[n] * inv(facts[r]) % Mod * inv(facts[n - r]) % Mod;
int[] numer = new int[r], denom = new int[r];
for (int k = 0; k < r; k++) { numer[k] = n - r + k + 1; denom[k] = k + 1; }
for (int p = 2; p <= r; p++) {
int piv = denom[p - 1];
if (piv > 1) {
int ofst = (n - r) % p;
for (int k = p - 1; k < r; k += p) { numer[k - ofst] /= piv; denom[k] /= piv; }
}
}
long ret = 1;
for (int k = 0; k < r; k++) if (numer[k] > 1) ret = ret * numer[k] % Mod;
return ret;
}
public static long[][] getcombs(int n) {
var ret = new long[n + 1][];
for (int i = 0; i <= n; i++) {
ret[i] = new long[i + 1];
ret[i][0] = ret[i][i] = 1;
for (int j = 1; j < i; j++) ret[i][j] = (ret[i - 1][j - 1] + ret[i - 1][j]) % Mod;
}
return ret;
}
// nC0, nC2, ..., nCn
public static long[] getcomb(int n) {
var ret = new long[n + 1];
ret[0] = 1;
for (int i = 0; i < n; i++) ret[i + 1] = ret[i] * (n - i) % Mod * inv(i + 1) % Mod;
return ret;
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 31, 22], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 17, 33], ["+", 15, 16, 12, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 31, 16, 12, 16, 12, 16, 31, 16, 31, 22], ["+", 31, 16, 12, 16, 12, 16, 31, 16, 17, 33], ["+", 31, 16, 12, 16, 12, 16, 31, 16, 12, 22], ["+", 15, 16, 31, 16, 12, 16, 12, 16, 17, 72], ["+", 15, 16, 31, 16, 12, 16, 12, 16, 12, 22], ["+", 12, 16, 12, 16, 31, 16, 31, 16, 31, 22], ["+", 12, 16, 12, 16, 31, 16, 31, 16, 17, 33], ["+", 12, 16, 12, 16, 31, 16, 31, 16, 12, 203]]
| 8
| 4,964
| 26
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int[] HW =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int H = HW[0];
int W = HW[1];
char[,] hairetu = new char[H, W];
for (int i = 0; i < H; i++) {
char[] tmp = Console.ReadLine().ToCharArray();
for (int j = 0; j < W; j++) {
hairetu[i, j] = tmp[j];
}
}
List<int> num = new List<int>();
Boolean[,] yoko = new Boolean[H, W];
Boolean[,] tate = new Boolean[H, W];
for (int i = 0; i < H; i++) {
Boolean flg = false;
for (int j = 0; j < W; j++) {
if (num.Contains(j)) {
continue;
}
if (hairetu[i, j] == '#') {
num.Add(j);
flg = true;
}
}
if (flg) {
for (int j = 0; j < W; j++) {
yoko[i, j] = true;
}
}
}
if (num.Count != 0) {
for (int j = 0; j < num.Count; j++) {
for (int i = 0; i < H; i++) {
tate[i, num[j]] = true;
}
}
}
string ans = "";
for (int i = 0; i < H; i++) {
Boolean f = false;
for (int j = 0; j < W; j++) {
if (tate[i, j] && yoko[i, j]) {
ans += hairetu[i, j].ToString();
f = true;
}
}
if (f) {
ans += "\n";
}
}
Console.WriteLine(ans);
}
}
}
// int n = int.Parse(Console.ReadLine());
// int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int[] HW =
Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
int H = HW[0];
int W = HW[1];
char[,] hairetu = new char[H, W];
for (int i = 0; i < H; i++) {
char[] tmp = Console.ReadLine().ToCharArray();
for (int j = 0; j < W; j++) {
hairetu[i, j] = tmp[j];
}
}
List<int> num = new List<int>();
Boolean[,] yoko = new Boolean[H, W];
Boolean[,] tate = new Boolean[H, W];
for (int i = 0; i < H; i++) {
Boolean flg = false;
for (int j = 0; j < W; j++) {
if (hairetu[i, j] == '#') {
if (!num.Contains(j)) {
num.Add(j);
}
flg = true;
}
}
if (flg) {
for (int j = 0; j < W; j++) {
yoko[i, j] = true;
}
}
}
if (num.Count != 0) {
for (int j = 0; j < num.Count; j++) {
for (int i = 0; i < H; i++) {
tate[i, num[j]] = true;
}
}
}
string ans = "";
for (int i = 0; i < H; i++) {
Boolean f = false;
for (int j = 0; j < W; j++) {
if (tate[i, j] && yoko[i, j]) {
ans += hairetu[i, j].ToString();
f = true;
}
}
if (f) {
ans += "\n";
}
}
Console.WriteLine(ans);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 57, 15, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 57, 15, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 57, 15, 213, 3, 4, 0, 24], ["-", 0, 57, 15, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 57, 15, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["+", 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, 241, 0, 111], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 205, 22], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 0, 131], ["+", 0, 57, 15, 241, 0, 213, 63, 214, 141, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 24], ["+", 15, 241, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 57, 15, 241, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 25], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 461
| 25
|
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 h = cin.nextInt();
var w = cin.nextInt();
var f = new string[h, w];
var zero = new string[h, w];
for (int i = 0; i < h; i++) {
var s = cin.next().ToCharArray();
for (int j = 0; j < w; j++) {
f[i, j] = s[j].ToString();
}
}
for (int i = 0; i < h; i++) {
var ff = true;
var top = f[i, 0];
for (int j = 0; j < w; j++) {
if (top != f[i, j] && f[i, j] != "0")
ff = false;
}
if (ff) {
for (int j = 0; j < w; j++) {
zero[i, j] = "0";
}
}
}
for (int i = 0; i < w; i++) {
var ff = true;
var top = f[0, i];
for (int j = 0; j < h; j++) {
if (top != f[j, i] && f[j, i] != "0")
ff = false;
}
if (ff) {
for (int j = 0; j < h; j++) {
zero[j, i] = "0";
}
}
}
for (int i = 0; i < h; i++) {
var ff = true;
for (int j = 0; j < w; j++) {
if (zero[i, j] != "0")
ff = false;
if (zero[i, j] != "0")
Console.Write(f[i, j]);
}
if (!ff)
Console.WriteLine();
}
Console.WriteLine();
}
}
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 h = cin.nextInt();
var w = cin.nextInt();
var f = new string[h, w];
var zero = new string[h, w];
for (int i = 0; i < h; i++) {
var s = cin.next().ToCharArray();
for (int j = 0; j < w; j++) {
f[i, j] = s[j].ToString();
}
}
for (int i = 0; i < h; i++) {
var ff = true;
var top = ".";
for (int j = 0; j < w; j++) {
if (top != f[i, j] && f[i, j] != "0")
ff = false;
}
if (ff) {
for (int j = 0; j < w; j++) {
zero[i, j] = "0";
}
}
}
for (int i = 0; i < w; i++) {
var ff = true;
var top = ".";
for (int j = 0; j < h; j++) {
if (top != f[j, i] && f[j, i] != "0")
ff = false;
}
if (ff) {
for (int j = 0; j < h; j++) {
zero[j, i] = "0";
}
}
}
for (int i = 0; i < h; i++) {
var ff = true;
for (int j = 0; j < w; j++) {
if (zero[i, j] != "0")
ff = false;
if (zero[i, j] != "0")
Console.Write(f[i, j]);
}
if (!ff)
Console.WriteLine();
}
Console.WriteLine();
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public int[] DPArrayInt(int N, int ex) {
int[] Array = new int[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextInt();
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public long[] DPArrayLong(int N, int ex) {
long[] Array = new long[N + ex];
for (int i = 0; i < N; i++) {
Array[i] = nextLong();
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Program {
static void Main(string[] s) => new Solver().Solve();
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 204, 205, 22], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 70], ["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 22], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 21], ["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 200, 0, 212, 0, 204, 206, 207, 0, 73], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 62], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222]]
| 8
| 948
| 18
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
int H;
int W;
Multi(out H, out W);
var cell = new char [H][];
for (int i = 0; i < H; i++) {
cell[i] = GetStr().ToCharArray();
}
cell = cell.Where(c => c.Any(a => a == '#')).ToArray();
var rcell = new char [W][];
for (int i = 0; i < W; i++) {
rcell[i] = new char[cell.Count()];
for (int j = 0; j < cell.Count(); j++) {
rcell[i][j] = cell[j][i];
}
}
rcell = rcell.Where(c => c.Any(a => a == '#')).ToArray();
cell = new char [cell.Count()][];
for (int i = 0; i < cell.Count(); i++) {
cell[i] = new char[rcell.Count()];
for (int j = 0; j < rcell.Count(); j++) {
cell[i][j] = rcell[j][i];
}
WriteObjects(cell[i]);
Console.WriteLine("");
}
}
static public string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder {
class Program {
static void Main() {
Solve();
Console.ReadKey();
}
static void Solve() {
int H;
int W;
Multi(out H, out W);
var cell = new char [H][];
for (int i = 0; i < H; i++) {
cell[i] = GetStr().ToCharArray();
}
cell = cell.Where(c => c.Any(a => a == '#')).ToArray();
var rcell = new char [W][];
for (int i = 0; i < W; i++) {
rcell[i] = new char[cell.Count()];
for (int j = 0; j < cell.Count(); j++) {
rcell[i][j] = cell[j][i];
}
}
rcell = rcell.Where(c => c.Any(a => a == '#')).ToArray();
cell = new char [cell.Count()][];
for (int i = 0; i < cell.Count(); i++) {
cell[i] = new char[rcell.Count()];
for (int j = 0; j < rcell.Count(); j++) {
cell[i][j] = rcell[j][i];
}
Console.WriteLine(new string(cell[i]));
}
}
static public string GetStr() { return Console.ReadLine(); }
static public int GetInt() { return int.Parse(Console.ReadLine()); }
static public long GetLong() { return long.Parse(Console.ReadLine()); }
static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
static public int[] GetIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] GetLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<double> GetDoubleList() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToList();
}
static public void WriteObjects<T>(IEnumerable<T> values) {
foreach (var o in values) {
Console.Write(o + " ");
}
}
static bool eq<T, U>() => typeof(T).Equals(typeof(U));
static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
static 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);
static void Multi<T>(out T a) => a = cv<T>(GetStr());
static void Multi<T, U>(out T a, out U b) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
}
static void Multi<T, U, V>(out T a, out U b, out V c) {
var ar = GetStrArray();
a = cv<T>(ar[0]);
b = cv<U>(ar[1]);
c = cv<V>(ar[2]);
}
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["+", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 230, 0, 228], ["+", 0, 213, 3, 4, 0, 28, 0, 230, 39, 199], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62]]
| 8
| 880
| 14
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
class Program {
static void Main(string[] args) { new Program().Calc(); }
Scanner cin;
public Program() {}
bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (b.CompareTo(a) < 0) {
a = b;
return true;
}
return false;
}
void Calc() {
cin = new Scanner();
int H = cin.nextInt();
int W = cin.nextInt();
char[][] grid = new char [H][];
int indexH = 0;
for (int i = 0; i < H; ++i) {
string str = cin.next();
if (str.IndexOf('#', 0, W) != -1) {
grid[indexH] = str.ToCharArray();
indexH++;
}
}
char[][] gridAns = new char [indexH][];
int indexW = 0;
for (int j = 0; j < indexH; ++j) {
gridAns[j] = new char[W];
}
for (int i = 0; i < W; ++i) {
bool allWhite = true;
for (int j = 0; j < indexH; ++j) {
if (grid[j][i] == '#') {
allWhite = false;
break;
}
}
if (!allWhite) {
for (int j = 0; j < indexH; ++j) {
gridAns[j][indexW] = grid[j][i];
}
indexW++;
}
}
for (int i = 0; i < indexH; ++i) {
WriteLine(new string(gridAns[i]));
}
}
}
public static class StringExtension {
public static char GetChar1(this string str, int indexOneBase) {
return str[indexOneBase - 1];
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
class Program {
static void Main(string[] args) { new Program().Calc(); }
Scanner cin;
public Program() {}
bool chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) < 0) {
a = b;
return true;
}
return false;
}
bool chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (b.CompareTo(a) < 0) {
a = b;
return true;
}
return false;
}
void Calc() {
cin = new Scanner();
int H = cin.nextInt();
int W = cin.nextInt();
char[][] grid = new char [H][];
int indexH = 0;
for (int i = 0; i < H; ++i) {
string str = cin.next();
if (str.IndexOf('#', 0, W) != -1) {
grid[indexH] = str.ToCharArray();
indexH++;
}
}
char[][] gridAns = new char [indexH][];
int indexW = 0;
for (int j = 0; j < indexH; ++j) {
gridAns[j] = new char[W];
}
for (int i = 0; i < W; ++i) {
bool allWhite = true;
for (int j = 0; j < indexH; ++j) {
if (grid[j][i] == '#') {
allWhite = false;
break;
}
}
if (!allWhite) {
for (int j = 0; j < indexH; ++j) {
gridAns[j][indexW] = grid[j][i];
}
indexW++;
}
}
for (int i = 0; i < indexH; ++i) {
for (int j = 0; j < indexW; ++j) {
Write(gridAns[i][j].ToString());
}
Write("\n");
// WriteLine(new string(gridAns[i]));
}
}
}
public static class StringExtension {
public static char GetChar1(this string str, int indexOneBase) {
return str[indexOneBase - 1];
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["-", 0, 7, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 88], ["-", 0, 213, 3, 4, 0, 28, 0, 230, 0, 228], ["-", 0, 213, 3, 4, 0, 28, 0, 230, 39, 199], ["+", 0, 7, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 8, 196, 0, 7, 10, 198, 0, 200, 141, 22], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 35], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 7, 26, 241, 0, 29], ["+", 0, 7, 8, 196, 0, 7, 26, 241, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 7, 0, 25], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 1, 0, 213, 63, 22], ["+", 0, 213, 63, 214, 205, 204, 206, 207, 0, 70], ["+", 63, 214, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 0, 213, 63, 214, 205, 204, 206, 207, 0, 73], ["+", 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], ["+", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 196, 0, 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, 44]]
| 8
| 820
| 32
|
using System;
using System.Collections.Generic;
public class Test {
public static void Main() {
int h, w, ii, jj;
string[] tmp;
List<int> hl, wl;
tmp = Console.ReadLine().Split(' ');
h = int.Parse(tmp[0]);
w = int.Parse(tmp[1]);
string[] a, b;
a = new string[h];
b = new string[h];
Console.WriteLine(h);
for (ii = 0; ii < h; ii++) {
a[ii] = Console.ReadLine();
}
hl = new List<int>();
wl = new List<int>();
for (ii = 0; ii < h; ii++) {
for (jj = 0; jj < w; jj++) {
if (a[ii][jj] == '.') {
} else {
break;
}
}
if (jj == w) {
hl.Add(ii);
// Console.WriteLine("yes" + a[ii]);
}
}
for (ii = 0; ii < w; ii++) {
for (jj = 0; jj < h; jj++) {
if (a[jj][ii] == '.') {
} else {
break;
}
}
if (jj == h) {
// Console.WriteLine("yes" + a[ii]);
wl.Add(ii);
}
}
for (ii = 0; ii < h; ii++) {
for (jj = 0; jj < w; jj++) {
if (!hl.Contains(ii) && !wl.Contains(jj)) {
Console.Write(a[ii][jj]);
}
}
if (!hl.Contains(ii)) {
Console.WriteLine();
}
}
}
}
|
using System;
using System.Collections.Generic;
public class Test {
public static void Main() {
int h, w, ii, jj;
string[] tmp;
List<int> hl, wl;
tmp = Console.ReadLine().Split(' ');
h = int.Parse(tmp[0]);
w = int.Parse(tmp[1]);
string[] a, b;
a = new string[h];
b = new string[h];
// Console.WriteLine(h);
for (ii = 0; ii < h; ii++) {
a[ii] = Console.ReadLine();
}
hl = new List<int>();
wl = new List<int>();
for (ii = 0; ii < h; ii++) {
for (jj = 0; jj < w; jj++) {
if (a[ii][jj] == '.') {
} else {
break;
}
}
if (jj == w) {
hl.Add(ii);
// Console.WriteLine("yes" + a[ii]);
}
}
for (ii = 0; ii < w; ii++) {
for (jj = 0; jj < h; jj++) {
if (a[jj][ii] == '.') {
} else {
break;
}
}
if (jj == h) {
// Console.WriteLine("yes" + a[ii]);
wl.Add(ii);
}
}
for (ii = 0; ii < h; ii++) {
for (jj = 0; jj < w; jj++) {
if (!hl.Contains(ii) && !wl.Contains(jj)) {
Console.Write(a[ii][jj]);
}
}
if (!hl.Contains(ii)) {
Console.WriteLine();
}
}
}
}
|
[["-", 8, 196, 0, 1, 0, 213, 63, 214, 205, 22], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 0, 131], ["-", 8, 196, 0, 1, 0, 213, 63, 214, 141, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 8, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 375
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
class Program {
static void Main() {
int[] hw =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int H = hw[0];
int W = hw[1];
bool[] rows = new bool[H];
bool[] columns = new bool[W];
char[] data = new char[H * W];
for (int i = 0; i < H; i++) {
char[] lineData = Console.ReadLine().ToArray();
lineData.CopyTo(data, i * W);
}
var validRows =
Enumerable.Range(0, H)
.Where(y => Enumerable.Range(0, W).Any(x => data[H * y + x] == '#'))
.ToArray();
var validCols =
Enumerable.Range(0, W)
.Where(x => Enumerable.Range(0, H).Any(y => data[H * y + x] == '#'))
.ToArray();
foreach (var y in validRows) {
foreach (var x in validCols) {
Console.Write(data[y * H + x]);
}
Console.WriteLine();
}
}
}
static class MathUtil {
public static IEnumerable<IEnumerable<int>> GetPermutation(int n) {
if (n == 0) {
yield return Single(0);
yield break;
}
for (int i = 0; i <= n; i++) {
foreach (var x in GetPermutation(n - 1)) {
yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
}
}
}
private static IEnumerable<int> Single(int x) { yield return x; }
public static IEnumerable<int> EnumeratePrimeNumbers() {
List<int> primes = new List<int>() { 2 };
yield return 2;
for (int i = 3; i < int.MaxValue; i++) {
bool isPrime = true;
int Sqrt = (int)Math.Sqrt(i) + 1;
foreach (var prime in primes) {
if (prime > Sqrt) {
break;
}
if (i % prime == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.Add(i);
yield return i;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
class Program {
static void Main() {
int[] hw =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int H = hw[0];
int W = hw[1];
char[] data = new char[H * W];
for (int i = 0; i < H; i++) {
char[] lineData = Console.ReadLine().ToArray();
lineData.CopyTo(data, i * W);
}
var validRows =
Enumerable.Range(0, H)
.Where(y => Enumerable.Range(0, W).Any(x => data[W * y + x] == '#'))
.ToArray();
var validCols =
Enumerable.Range(0, W)
.Where(x => Enumerable.Range(0, H).Any(y => data[W * y + x] == '#'))
.ToArray();
foreach (var y in validRows) {
foreach (var x in validCols) {
Console.Write(data[y * W + x]);
}
Console.WriteLine();
}
}
}
static class MathUtil {
public static IEnumerable<IEnumerable<int>> GetPermutation(int n) {
if (n == 0) {
yield return Single(0);
yield break;
}
for (int i = 0; i <= n; i++) {
foreach (var x in GetPermutation(n - 1)) {
yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
}
}
}
private static IEnumerable<int> Single(int x) { yield return x; }
public static IEnumerable<int> EnumeratePrimeNumbers() {
List<int> primes = new List<int>() { 2 };
yield return 2;
for (int i = 3; i < int.MaxValue; i++) {
bool isPrime = true;
int Sqrt = (int)Math.Sqrt(i) + 1;
foreach (var prime in primes) {
if (prime > Sqrt) {
break;
}
if (i % prime == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.Add(i);
yield return i;
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 70], ["-", 0, 197, 0, 198, 39, 224, 225, 226, 0, 73], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 198, 0, 200, 0, 212, 0, 227, 0, 228], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 70], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22], ["-", 0, 212, 0, 227, 39, 224, 225, 226, 0, 73], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 31, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 31, 22], ["-", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22], ["+", 206, 207, 0, 28, 0, 16, 31, 16, 12, 22]]
| 8
| 546
| 28
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace _0030 {
class Gyo {
internal int dot;
internal int sharp;
public Gyo() {
this.dot = 0;
this.sharp = 0;
}
}
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
int m = int.Parse(str[1]);
char[,] data = new char[n, m];
var delete_i = new List<int>(); //ๅใ้คใ่กใๅฐใใ้
var delete_j = new List<int>();
var gyo_delete_j = new Gyo[m]; //ๅใงๅ้คๅฏพๅฆใใฉใใใฎๅคๆญ
for (int j = 0; j < m; j++) {
gyo_delete_j[j] = new Gyo();
}
int count_dot = 0;
int count_sharp = 0;
string strer;
// i่กjๅ
for (int i = 0; i < n; i++) {
strer = Console.ReadLine();
count_dot = 0;
count_sharp = 0;
for (int j = 0; j < m; j++) {
data[i, j] = strer[j];
if (strer[j] == '.') {
count_dot++;
gyo_delete_j[j].dot = 1;
} else {
count_sharp++;
gyo_delete_j[j].sharp = 1;
}
//ๅใ้คใ่ก
if (count_dot == m) {
delete_i.Add(i);
} else if (count_sharp == m) {
delete_i.Add(i);
}
}
}
for (int j = 0; j < m; j++) {
if (gyo_delete_j[j].dot == 1 && gyo_delete_j[j].sharp == 1) {
continue;
} else {
delete_j.Add(j);
}
}
// Console.WriteLine();
//ๅ้คใใ่กใจๅใ่กจ็คบใใชใใง
for (int i = 0; i < n; i++) {
if (delete_i.Contains(i)) {
continue;
}
for (int j = 0; j < m; j++) {
if (delete_j.Contains(j)) {
continue;
}
Console.Write(data[i, j]);
}
Console.WriteLine();
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace _0030 {
class Gyo {
internal int dot;
internal int sharp;
public Gyo() {
this.dot = 0;
this.sharp = 0;
}
}
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
int m = int.Parse(str[1]);
char[,] data = new char[n, m];
var delete_i = new List<int>(); //ๅใ้คใ่ก
var delete_j = new List<int>(); //ๅใ้คใๅ
var gyo_delete_j = new Gyo[m]; //ๅๅใๅ้คๅฏพๅฆใใฉใใใฎๅคๆญ
// gyo_delete_jใฎใคใณในใฟใณในใไฝๆ
for (int j = 0; j < m; j++) {
gyo_delete_j[j] = new Gyo();
}
int count_dot = 0;
string strer;
// i่กjๅ
for (int i = 0; i < n; i++) {
strer = Console.ReadLine();
count_dot = 0;
for (int j = 0; j < m; j++) {
data[i, j] = strer[j];
//ใใใใจใทใฃใผใใใซใฆใณใ
//ใใใใจใทใฃใผใใใใฃใใ1ใงๅญๅจใ่จผๆ
if (strer[j] == '.') {
count_dot++;
gyo_delete_j[j].dot = 1;
} else {
gyo_delete_j[j].sharp = 1;
}
//ๅใ้คใ่ก
// mๅใชใใใงใใๅใ้คใ
if (count_dot == m) {
delete_i.Add(i);
}
}
}
//ๅ้คใใๅใฎ็บ่ฆ
for (int j = 0; j < m; j++) {
//ใฉใฃใกใ1๏ผๅญๅจใใฆใใ๏ผใ ใฃใใๅ้คใใชใ
if (gyo_delete_j[j].dot == 1 && gyo_delete_j[j].sharp == 0) {
delete_j.Add(j);
}
}
// Console.WriteLine();
//ๅ้คใใ่กใจๅไปฅๅคใ่กจ็คบ
for (int i = 0; i < n; i++) {
if (delete_i.Contains(i)) {
continue;
}
for (int j = 0; j < m; j++) {
if (delete_j.Contains(j)) {
continue;
}
Console.Write(data[i, j]);
}
Console.WriteLine();
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 12, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["-", 0, 57, 75, 196, 0, 1, 0, 223, 0, 29], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["-", 0, 7, 8, 196, 0, 57, 75, 57, 0, 121], ["-", 0, 7, 8, 196, 0, 57, 75, 57, 0, 24], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 31, 22], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 60], ["-", 8, 196, 0, 57, 75, 57, 15, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 75, 57, 0, 25], ["-", 8, 196, 0, 57, 75, 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], ["-", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 35], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 455
| 35
|
using System;
using System.Linq;
public class Hello {
public static void Main() {
// Your code here!
int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int H = a[0];
int W = a[1];
char[,] matrix = new char[H, W];
for (int h = 0; h < H; h++) {
string line = Console.ReadLine();
for (int w = 0; w < W; w++) {
matrix[h, w] = line[w];
}
}
//ใทใใฅใฌใผใทใงใณ
for (int h = 0; h < H; h++) //่กใๆถใ
{
int flag = 0;
for (int w = 0; w < W; w++) {
if (matrix[h, w] == '#') //้ปใใใฃใใ
{
flag = 1;
break;
}
}
if (flag == 0) // h่ก็ฎใๅ
จ้จ็ฝใชใใฐ
{
// h่ก็ฎใๅ
จ้จๆถใ
for (int w = 0; w < W; w++) {
matrix[h, w] = 'o';
}
}
}
for (int w = 0; w < W; w++) //ๅใๆถใ
{
int flag = 0;
for (int h = 0; h < H; h++) {
if (matrix[h, w] == '#') //้ปใใใฃใใ
{
flag = 1;
break;
}
}
if (flag == 0) // wๅ็ฎใๅ
จ้จ็ฝใชใใฐ
{
// wๅ็ฎใๅ
จ้จๆถใ
for (int h = 0; h < H; h++) {
matrix[h, w] = 'o';
}
}
}
for (int h = 0; h < H; h++) //ๅบๅ
{
int flag = 0;
for (int w = 0; w < W; w++) {
if (matrix[h, w] != 'o') {
Console.Write(matrix[h, w]);
flag = 0;
}
if (matrix[h, w] == 'o') {
flag = 1;
}
}
if (flag == 0) {
Console.WriteLine();
}
}
}
}
|
using System;
using System.Linq;
public class Hello {
public static void Main() {
// Your code here!
int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int H = a[0];
int W = a[1];
char[,] matrix = new char[H, W];
for (int h = 0; h < H; h++) {
string line = Console.ReadLine();
for (int w = 0; w < W; w++) {
matrix[h, w] = line[w];
}
}
//ใทใใฅใฌใผใทใงใณ
for (int h = 0; h < H; h++) //่กใๆถใ
{
int flag = 0;
for (int w = 0; w < W; w++) {
if (matrix[h, w] == '#') //้ปใใใฃใใ
{
flag = 1;
break;
}
}
if (flag == 0) // h่ก็ฎใๅ
จ้จ็ฝใชใใฐ
{
// h่ก็ฎใๅ
จ้จๆถใ
for (int w = 0; w < W; w++) {
matrix[h, w] = 'o';
}
}
}
for (int w = 0; w < W; w++) //ๅใๆถใ
{
int flag = 0;
for (int h = 0; h < H; h++) {
if (matrix[h, w] == '#') //้ปใใใฃใใ
{
flag = 1;
break;
}
}
if (flag == 0) // wๅ็ฎใๅ
จ้จ็ฝใชใใฐ
{
// wๅ็ฎใๅ
จ้จๆถใ
for (int h = 0; h < H; h++) {
matrix[h, w] = 'o';
}
}
}
for (int h = 0; h < H; h++) //ๅบๅ
{
bool newLine = false;
for (int w = 0; w < W; w++) {
if (matrix[h, w] != 'o') {
Console.Write(matrix[h, w]);
newLine = true;
}
}
if (newLine == true) {
Console.WriteLine();
}
}
/*
for(int h = 0; h < H; h++) //ๅบๅ
{
for(int w = 0; w < W; w++)
{
Console.Write(matrix[h,w]);
}
Console.WriteLine();
}
*/
}
}
|
[["-", 0, 7, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 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, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 211, 0, 147], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 24], ["-", 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, 21], ["-", 0, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 60], ["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 104], ["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 64, 196, 0, 1, 0, 11, 12, 211, 0, 146], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 211, 0, 146]]
| 8
| 436
| 33
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int H = int.Parse(s.Split(' ')[0]);
int W = int.Parse(s.Split(' ')[1]);
List<string> Rows = new List<string>();
for (int i = 0; i < H; i++) {
string str = Console.ReadLine();
if (str.Contains("#")) {
Rows.Add(str);
}
}
bool[] WhiteColumn = Enumerable.Repeat(true, W).ToArray();
for (int j = 0; j < W; j++) {
for (int i = 0; i < Rows.Count; i++) {
if (Rows[i][j] != '.') {
WhiteColumn[j] = false;
break;
}
}
}
for (int i = 0; i < W; i++) {
if (WhiteColumn[i]) {
for (int j = 0; j < Rows.Count; j++) {
Rows[j] = Rows[j].Remove(i, 1);
}
}
}
for (int i = 0; i < Rows.Count; i++) {
if (Rows[i].Contains("#")) {
Console.WriteLine(Rows[i]);
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int H = int.Parse(s.Split(' ')[0]);
int W = int.Parse(s.Split(' ')[1]);
List<string> Rows = new List<string>();
for (int i = 0; i < H; i++) {
string str = Console.ReadLine();
if (str.Contains("#")) {
Rows.Add(str);
}
}
bool[] WhiteColumn = Enumerable.Repeat(true, W).ToArray();
for (int j = 0; j < W; j++) {
for (int i = 0; i < Rows.Count; i++) {
if (Rows[i][j] != '.') {
WhiteColumn[j] = false;
break;
}
}
}
for (int i = W - 1; 0 <= i; i--) {
if (WhiteColumn[i]) {
for (int j = 0; j < Rows.Count; j++) {
Rows[j] = Rows[j].Remove(i, 1);
}
}
}
for (int i = 0; i < Rows.Count; i++) {
if (Rows[i].Contains("#")) {
Console.WriteLine(Rows[i]);
}
}
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 31, 22], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 10, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 31, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 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, 29], ["+", 0, 195, 8, 196, 0, 7, 26, 223, 0, 68]]
| 8
| 335
| 10
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var h = int.Parse(line[0]);
var w = int.Parse(line[1]);
var buf = new string[h];
var ha = new bool[h];
var wa = new bool[w];
for (int i = 0; i < h; i++) {
var s = Console.ReadLine().Trim();
buf[i] = s;
for (int j = 0; j < w; j++)
if (s[j] == '#') {
wa[j] = true;
ha[i] = true;
}
}
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (ha[i] && wa[j])
if (j != w - 1)
Console.Write(buf[i][j]);
else
Console.WriteLine(buf[i][j]);
}
}
|
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var h = int.Parse(line[0]);
var w = int.Parse(line[1]);
var buf = new string[h];
var ha = new bool[h];
var wa = new bool[w];
for (int i = 0; i < h; i++) {
var s = Console.ReadLine().Trim();
buf[i] = s;
for (int j = 0; j < w; j++)
if (s[j] == '#') {
wa[j] = true;
ha[i] = true;
}
}
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (ha[i] && wa[j])
if (j != w - 1)
Console.Write(buf[i][j]);
else
Console.WriteLine(buf[i][j]);
else if (ha[i] && j == w - 1)
Console.WriteLine();
}
}
|
[["+", 8, 196, 0, 7, 8, 7, 8, 57, 0, 95], ["+", 0, 7, 8, 7, 8, 57, 75, 57, 0, 121], ["+", 0, 7, 8, 7, 8, 57, 75, 57, 0, 24], ["+", 8, 57, 75, 57, 15, 16, 31, 204, 205, 22], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 70], ["+", 15, 16, 31, 204, 206, 207, 0, 28, 0, 22], ["+", 75, 57, 15, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 7, 8, 57, 75, 57, 15, 16, 17, 98], ["+", 8, 57, 75, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 57, 75, 57, 15, 16, 12, 16, 17, 60], ["+", 75, 57, 15, 16, 12, 16, 12, 16, 31, 22], ["+", 75, 57, 15, 16, 12, 16, 12, 16, 17, 33], ["+", 75, 57, 15, 16, 12, 16, 12, 16, 12, 203], ["+", 0, 7, 8, 7, 8, 57, 75, 57, 0, 25], ["+", 75, 57, 64, 1, 0, 213, 63, 214, 205, 22], ["+", 75, 57, 64, 1, 0, 213, 63, 214, 0, 131], ["+", 75, 57, 64, 1, 0, 213, 63, 214, 141, 22], ["+", 75, 57, 64, 1, 0, 213, 3, 4, 0, 24], ["+", 75, 57, 64, 1, 0, 213, 3, 4, 0, 25], ["+", 8, 7, 8, 57, 75, 57, 64, 1, 0, 35]]
| 8
| 243
| 20
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;
public class Hello {
public static void Main() {
int[] n = SpIntRead(' ');
int H = n[0];
int W = n[1];
string[] s = new string[H];
bool[] h = new bool[H];
bool[] w = new bool[W];
for (int i = 0; i < H; i++)
s[i] = Console.ReadLine();
for (int i = 0; i < H; i++) {
if (s[i].Count(c => c == s[i][0]) == W)
h[i] = false;
else
h[i] = true;
}
bool f = false;
for (int i = 0; i < W; i++) {
for (int j = 0; j < H; j++) {
if ('.' == s[j][i])
f = true;
else {
f = false;
break;
}
}
if (f)
w[i] = false;
else
w[i] = true;
}
bool write = false;
for (int i = 0; i < H; i++) {
if (!h[i])
continue;
write = false;
for (int j = 0; j < W; j++) {
if (h[i] && w[j]) {
Console.Write(s[i][j]);
write = true;
}
}
if (write)
Console.WriteLine();
}
}
}
public class Atcoder {
static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static long LCM(long a, long b) {
long c = a * b;
if (a < b)
Swap(ref a, ref b);
long d = a % b;
while (d != 0) {
a = b;
b = d;
d = a % b;
}
return c / b;
}
public static string strReverce(string s) {
return new string(s.Reverse().ToArray());
}
public static int intRead() { return int.Parse(Console.ReadLine()); }
public static bool IsPrime(int n) {
if (n < 2)
return false;
if (n == 2)
return true;
if (n % 2 == 0)
return false;
// double sqrtNum = Math.Sqrt(n);
for (int i = 3; i < n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
public static string[] SpRead(char c) { return Console.ReadLine().Split(c); }
public static int[] SpIntRead(char c) {
return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
}
public static string ToConvertBit(int N, int e) {
string ret = "";
int r = 0;
while (N != 0) {
r = N % e;
ret += r.ToString();
N -= r;
N /= e;
}
ret = strReverce(ret);
return ret;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;
public class Hello {
public static void Main() {
int[] n = SpIntRead(' ');
int H = n[0];
int W = n[1];
string[] s = new string[H];
bool[] h = new bool[H];
bool[] w = new bool[W];
for (int i = 0; i < H; i++)
s[i] = Console.ReadLine();
for (int i = 0; i < H; i++) {
if (s[i].Count(c => c == s[i][0]) == W && s[i][0] == '.')
h[i] = false;
else
h[i] = true;
}
bool f = false;
for (int i = 0; i < W; i++) {
for (int j = 0; j < H; j++) {
if ('.' == s[j][i])
f = true;
else {
f = false;
break;
}
}
if (f)
w[i] = false;
else
w[i] = true;
}
bool write = false;
for (int i = 0; i < H; i++) {
if (!h[i])
continue;
write = false;
for (int j = 0; j < W; j++) {
if (h[i] && w[j]) {
Console.Write(s[i][j]);
write = true;
}
}
if (write)
Console.WriteLine();
}
}
}
public class Atcoder {
static void Swap<T>(ref T a, ref T b) {
var t = a;
a = b;
b = t;
}
public static long LCM(long a, long b) {
long c = a * b;
if (a < b)
Swap(ref a, ref b);
long d = a % b;
while (d != 0) {
a = b;
b = d;
d = a % b;
}
return c / b;
}
public static string strReverce(string s) {
return new string(s.Reverse().ToArray());
}
public static int intRead() { return int.Parse(Console.ReadLine()); }
public static bool IsPrime(int n) {
if (n < 2)
return false;
if (n == 2)
return true;
if (n % 2 == 0)
return false;
// double sqrtNum = Math.Sqrt(n);
for (int i = 3; i < n; i += 2) {
if (n % i == 0)
return false;
}
return true;
}
public static string[] SpRead(char c) { return Console.ReadLine().Split(c); }
public static int[] SpIntRead(char c) {
return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
}
public static string ToConvertBit(int N, int e) {
string ret = "";
int r = 0;
while (N != 0) {
r = N % e;
ret += r.ToString();
N -= r;
N /= e;
}
ret = strReverce(ret);
return ret;
}
}
|
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 15, 16, 12, 16, 31, 204, 205, 204, 205, 22], ["+", 12, 16, 31, 204, 205, 204, 206, 207, 0, 70], ["+", 31, 204, 205, 204, 206, 207, 0, 28, 0, 22], ["+", 12, 16, 31, 204, 205, 204, 206, 207, 0, 73], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 70], ["+", 12, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 15, 16, 12, 16, 31, 204, 206, 207, 0, 73], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 60], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 104], ["+", 0, 57, 15, 16, 12, 16, 12, 252, 0, 253]]
| 8
| 710
| 12
|
using System;
using System.Linq;
class P {
static void Main() {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = n[0];
int K = n[1];
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans = int.MaxValue, tmp = 0;
for (int i = 0; i < N - K; i++) {
tmp = Math.Min(Math.Abs(x[i]) + Math.Abs(x[i + K - 1] - x[i]),
Math.Abs(x[i + K - 1]) + Math.Abs(x[i + K - 1] - x[i]));
ans = Math.Min(ans, tmp);
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
class P {
static void Main() {
int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = n[0];
int K = n[1];
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
int tmp = 0, ans = int.MaxValue;
for (int i = 0; i <= N - K; i++) {
tmp = Math.Min(Math.Abs(x[i]) + Math.Abs(x[i + K - 1] - x[i]),
Math.Abs(x[i + K - 1]) + Math.Abs(x[i + K - 1] - x[i]));
ans = Math.Min(ans, tmp);
}
Console.WriteLine(ans);
}
}
|
[["+", 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], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 0, 21], ["-", 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], ["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 203
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// var data = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// var t = data[0];
// var s = data[1];
// int[,] friens = new int[t, t];
// int tomo = 0;
// for (int i = 0; i < s; i++)
// {
// var friend = Array.ConvertAll(Console.ReadLine().Split(),
// int.Parse); friens[friend[0] - 1, friend[1] - 1] = 1;
// friens[friend[1] - 1, friend[0] - 1] = 1;
// }
// for (int i = 0; i < t; i++)
// {
// var x = new List<int>();
// var y = new List<int>();
// var a = new List<int>();
// for (int j = 0; j < t; j++)
// {
// if (friens[i, j] == 1)
// {
// x.Add(j);
// }
// }
// foreach (var z in x)
// {
// for (int l = 0; l < t; l++)
// {
// if (friens[z, l] == 1)
// {
// y.Add(l);
// }
// }
// foreach (var m in y)
// {
// if (m != i && friens[m, i] != 1)
// {
// a.Add(m);
// }
// }
// }
// Console.WriteLine(a.Distinct().Count());
// }
// var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// var b = a[0];
// var c = a[1];
// int[] d = new int[b];
// int[] e = new int[b];
// int[] f = new int[b];
// int tmp = 0;
// int tokuten = 0;
// for (int i = 0; i < b; i++)
// {
// var g = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// d[i] = g[0];
// e[i] = g[1];
// f[i] = g[2];
// }
// for (int j = 1; j <= c; j++)
// {
// for (int k = 0; k < b; k++)
// {
// if (d[k] <= j && e[k] >= j)
// {
// }
// else
// {
// tmp += f[k];
// }
// }
// tokuten = Math.Max(tokuten ,tmp);
// tmp = 0;
// }
// Console.WriteLine(tokuten);
// var a = int.Parse(Console.ReadLine());
// var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// Dictionary<int,int> c = new Dictionary<int,int>();
// int d = 0;
// int cnt = 0;
////for (int i = 0; i < a; i++)
////{
//// c.Add(b[i], 1);
////}
// for (int i = 0; i < a; i++)
//{
// d = b[i];
// while (d % 2 == 0)
// {
// d /= 2;
// }
// if (c.ContainsKey(d))
// {
// }
// else
// {
// c.Add(d, 1);
// cnt++;
// }
//}
// Console.WriteLine(cnt);
// var one = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
// var N = one[0];
// var M = one[1];
// List<int[]> ID= new List<int[]>();
// List<string> Out = new List<string>();
// int cnt = 1;
// long now = -1;
// for (int i = 0; i < M; i++)
//{
// var morethanone = Array.ConvertAll(Console.ReadLine().Split(),
// int.Parse); ID.Add(morethanone);
//}
// var sortedID = ID.OrderBy(data => data[0]).ThenBy(data => data[1]);
// var Rank = new Dictionary<string, int>();
// foreach (var item in sortedID)
//{
// if (now != -1 && item[0] != now)
// {
// cnt = 1;
// }
// now = item[0];
// Rank.Add(item[0].ToString() + item[1].ToString(), cnt);
// cnt++;
//}
// for (int i = 0; i < M; i++)
//{
// var tmp = ID[i];
// string key = tmp[0].ToString() + tmp[1].ToString();
// string Output = tmp[0].ToString().PadLeft(6, '0') +
// Rank[key].ToString().PadLeft(6, '0'); Console.WriteLine(Output);
//}
// var N = int.Parse(Console.ReadLine());
// List<int[]> Z = new List<int[]>();
// List<int[]> dis = new List<int[]>();
// int X = 0;
// int Y = 0;
// int H = 0;
// for (int i = 0; i < N; i++)
//{
// var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// Z.Add(line);
//}
// row
// for (int i = 0; i < N; i++)
//{
// var linedata = Z[i];
// //height
// for (int j = 0; j < 201; j++)
// {
// //x
// for (int k = 0; k < 101; k++)
// {
// for (int l = 0; l < 101; l++)
// {
// if ((j + linedata[2]) - Math.Abs(k - linedata[0]) -
// Math.Abs(l - linedata[1]) == linedata[2])
// {
// X = k;
// Y = l;
// H = j;
// dis.Add(new {x = X,y =Y, h =H});
// }
// }
// }
// }
//}
// var a = dis.GroupBy(n => n)
// var b = a.OrderByDescending(n => n.cnt);
// var a = Console.ReadLine().ToCharArray();
// var b = Console.ReadLine().ToCharArray();
////char[] c = new char[a.Count()];
////char[] d = new char[a.Count()];
// var c = new Dictionary<char, char>();
// var d = new Dictionary<char, char>();
// for (int i = 0; i < a.Count(); i++)
//{
// if (!c.ContainsKey(a[i]))
// {
// c.Add(a[i], b[i]);
// }
// else if (c[a[i]] != b[i])
// {
// Console.WriteLine("No");
// return;
// }
//}
// for (int i = 0; i < b.Count(); i++)
//{
// if (!d.ContainsKey(b[i]))
// {
// d.Add(b[i], a[i]);
// }
// else if (d[b[i]] != a[i])
// {
// Console.WriteLine("No");
// return;
// }
//}
// Console.WriteLine("Yes");
// var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// var line2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// int min = int.MaxValue;
// int min2 = int.MaxValue;
// int amari = int.MaxValue;
// for (int i = 0; i < line1[0]; i++)
//{
// if (Math.Abs(line2[i]-line1[1]) <= min)
// {
// min2 = min;
// min = Math.Abs(line2[i] - line1[1]);
// }
// else if (Math.Abs(line2[i] - line1[1]) < min2)
// {
// min2 = Math.Abs(line2[i] - line1[1]);
// }
//}
// if (min2 != int.MaxValue)
//{
// while (amari != 0)
// {
// amari = min2 % min;
// min2 = min;
// min = amari;
// }
// Console.WriteLine(min2);
//}
// else
//{
// Console.WriteLine(min);
//}
// var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// int N = line1[0];
// int K = line1[1];
// int Kgaguu = 0;
// int amari0 = 0;
// for (int i = 1; i <= N; i++)
//{
// if (i % K == 0)
// {
// amari0++;
// }
// else if (K % 2 == 0 && i % K == K /2)
// {
// Kgaguu++;
// }
//}
// Console.WriteLine(amari0 * amari0 * amari0 + Kgaguu * Kgaguu * Kgaguu);
var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int N = line1[0];
int K = line1[1];
var line2 = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
long min = int.MaxValue;
for (int i = 0; i < N - K + 1; i++) {
var left = line2[i];
var right = line2[i + K - 1];
min = Math.Min(Math.Abs(left) + Math.Abs(right - left), min);
}
// for (int i = 0; i < N; i++)
//{
// if (i != 0 || i != N-1)
// {
// var tmp = new node();
// tmp._to1 = line2[i - 1];
// tmp._to2 = line2[i + 1];
// tmp.me = line2[i];
// tmp.flg = false;
// node.Add(tmp);
// }
//}
Console.WriteLine(min);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Atcoder {
class Program {
static void Main(string[] args) {
// var data = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// var t = data[0];
// var s = data[1];
// int[,] friens = new int[t, t];
// int tomo = 0;
// for (int i = 0; i < s; i++)
// {
// var friend = Array.ConvertAll(Console.ReadLine().Split(),
// int.Parse); friens[friend[0] - 1, friend[1] - 1] = 1;
// friens[friend[1] - 1, friend[0] - 1] = 1;
// }
// for (int i = 0; i < t; i++)
// {
// var x = new List<int>();
// var y = new List<int>();
// var a = new List<int>();
// for (int j = 0; j < t; j++)
// {
// if (friens[i, j] == 1)
// {
// x.Add(j);
// }
// }
// foreach (var z in x)
// {
// for (int l = 0; l < t; l++)
// {
// if (friens[z, l] == 1)
// {
// y.Add(l);
// }
// }
// foreach (var m in y)
// {
// if (m != i && friens[m, i] != 1)
// {
// a.Add(m);
// }
// }
// }
// Console.WriteLine(a.Distinct().Count());
// }
// var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// var b = a[0];
// var c = a[1];
// int[] d = new int[b];
// int[] e = new int[b];
// int[] f = new int[b];
// int tmp = 0;
// int tokuten = 0;
// for (int i = 0; i < b; i++)
// {
// var g = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// d[i] = g[0];
// e[i] = g[1];
// f[i] = g[2];
// }
// for (int j = 1; j <= c; j++)
// {
// for (int k = 0; k < b; k++)
// {
// if (d[k] <= j && e[k] >= j)
// {
// }
// else
// {
// tmp += f[k];
// }
// }
// tokuten = Math.Max(tokuten ,tmp);
// tmp = 0;
// }
// Console.WriteLine(tokuten);
// var a = int.Parse(Console.ReadLine());
// var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// Dictionary<int,int> c = new Dictionary<int,int>();
// int d = 0;
// int cnt = 0;
////for (int i = 0; i < a; i++)
////{
//// c.Add(b[i], 1);
////}
// for (int i = 0; i < a; i++)
//{
// d = b[i];
// while (d % 2 == 0)
// {
// d /= 2;
// }
// if (c.ContainsKey(d))
// {
// }
// else
// {
// c.Add(d, 1);
// cnt++;
// }
//}
// Console.WriteLine(cnt);
// var one = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
// var N = one[0];
// var M = one[1];
// List<int[]> ID= new List<int[]>();
// List<string> Out = new List<string>();
// int cnt = 1;
// long now = -1;
// for (int i = 0; i < M; i++)
//{
// var morethanone = Array.ConvertAll(Console.ReadLine().Split(),
// int.Parse); ID.Add(morethanone);
//}
// var sortedID = ID.OrderBy(data => data[0]).ThenBy(data => data[1]);
// var Rank = new Dictionary<string, int>();
// foreach (var item in sortedID)
//{
// if (now != -1 && item[0] != now)
// {
// cnt = 1;
// }
// now = item[0];
// Rank.Add(item[0].ToString() + item[1].ToString(), cnt);
// cnt++;
//}
// for (int i = 0; i < M; i++)
//{
// var tmp = ID[i];
// string key = tmp[0].ToString() + tmp[1].ToString();
// string Output = tmp[0].ToString().PadLeft(6, '0') +
// Rank[key].ToString().PadLeft(6, '0'); Console.WriteLine(Output);
//}
// var N = int.Parse(Console.ReadLine());
// List<int[]> Z = new List<int[]>();
// List<int[]> dis = new List<int[]>();
// int X = 0;
// int Y = 0;
// int H = 0;
// for (int i = 0; i < N; i++)
//{
// var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// Z.Add(line);
//}
// row
// for (int i = 0; i < N; i++)
//{
// var linedata = Z[i];
// //height
// for (int j = 0; j < 201; j++)
// {
// //x
// for (int k = 0; k < 101; k++)
// {
// for (int l = 0; l < 101; l++)
// {
// if ((j + linedata[2]) - Math.Abs(k - linedata[0]) -
// Math.Abs(l - linedata[1]) == linedata[2])
// {
// X = k;
// Y = l;
// H = j;
// dis.Add(new {x = X,y =Y, h =H});
// }
// }
// }
// }
//}
// var a = dis.GroupBy(n => n)
// var b = a.OrderByDescending(n => n.cnt);
// var a = Console.ReadLine().ToCharArray();
// var b = Console.ReadLine().ToCharArray();
////char[] c = new char[a.Count()];
////char[] d = new char[a.Count()];
// var c = new Dictionary<char, char>();
// var d = new Dictionary<char, char>();
// for (int i = 0; i < a.Count(); i++)
//{
// if (!c.ContainsKey(a[i]))
// {
// c.Add(a[i], b[i]);
// }
// else if (c[a[i]] != b[i])
// {
// Console.WriteLine("No");
// return;
// }
//}
// for (int i = 0; i < b.Count(); i++)
//{
// if (!d.ContainsKey(b[i]))
// {
// d.Add(b[i], a[i]);
// }
// else if (d[b[i]] != a[i])
// {
// Console.WriteLine("No");
// return;
// }
//}
// Console.WriteLine("Yes");
// var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// var line2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// int min = int.MaxValue;
// int min2 = int.MaxValue;
// int amari = int.MaxValue;
// for (int i = 0; i < line1[0]; i++)
//{
// if (Math.Abs(line2[i]-line1[1]) <= min)
// {
// min2 = min;
// min = Math.Abs(line2[i] - line1[1]);
// }
// else if (Math.Abs(line2[i] - line1[1]) < min2)
// {
// min2 = Math.Abs(line2[i] - line1[1]);
// }
//}
// if (min2 != int.MaxValue)
//{
// while (amari != 0)
// {
// amari = min2 % min;
// min2 = min;
// min = amari;
// }
// Console.WriteLine(min2);
//}
// else
//{
// Console.WriteLine(min);
//}
// var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
// int N = line1[0];
// int K = line1[1];
// int Kgaguu = 0;
// int amari0 = 0;
// for (int i = 1; i <= N; i++)
//{
// if (i % K == 0)
// {
// amari0++;
// }
// else if (K % 2 == 0 && i % K == K /2)
// {
// Kgaguu++;
// }
//}
// Console.WriteLine(amari0 * amari0 * amari0 + Kgaguu * Kgaguu * Kgaguu);
var line1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int N = line1[0];
int K = line1[1];
var line2 = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
long mintmp = int.MaxValue;
long min = int.MaxValue;
for (int i = 0; i < N - K + 1; i++) {
var left = line2[i];
var right = line2[i + K - 1];
mintmp = Math.Min(Math.Min(Math.Abs(left) + Math.Abs(right - left), min),
Math.Abs(right) + Math.Abs(left - right));
min = Math.Min(mintmp, min);
}
// for (int i = 0; i < N; i++)
//{
// if (i != 0 || i != N-1)
// {
// var tmp = new node();
// tmp._to1 = line2[i - 1];
// tmp._to2 = line2[i + 1];
// tmp.me = line2[i];
// tmp.flg = false;
// node.Add(tmp);
// }
//}
Console.WriteLine(min);
}
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 205, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 0, 131], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 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], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 213, 3, 4, 0, 28, 0, 22], ["+", 3, 4, 0, 28, 0, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 21], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 205, 22], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 0, 131], ["+", 0, 28, 0, 16, 31, 213, 63, 214, 141, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 24], ["+", 0, 16, 31, 213, 3, 4, 0, 28, 0, 22], ["+", 0, 28, 0, 16, 31, 213, 3, 4, 0, 25], ["+", 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, 7, 8, 196, 0, 1, 0, 35], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 0, 11, 12, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 443
| 41
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.