buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC104C {
static class MainClass {
public static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
int D = int.Parse(input1[0]);
int G = int.Parse(input1[1]);
var plst = new List<int>();
var clst = new List<int>();
var RestDlst = new List<int>();
var Dmemolst = new List<int>();
int p = 0;
int c = 0;
for (int i = 0; i < D; i++) {
string[] input2 = Console.ReadLine().Split(' ');
p = int.Parse(input2[0]);
c = int.Parse(input2[1]);
plst.Add(p);
clst.Add(c);
RestDlst.Add(i + 1);
Dmemolst.Add(p * (i + 1) * 100 + c);
}
int ans = 1000000000;
for (int mask = 0; mask < (1 << D); mask++) {
int pt = 0, restmax = -1, num = 0;
//その0101...でのptを計算
for (int i = 0; i < D; i++) {
if ((mask >> i) == 1) {
pt += 100 * (i + 1) * plst[i] + clst[i];
num += plst[i];
} else {
restmax = i;
}
}
// Gに達していなければ、restmaxを中途半端に解く
if (pt < G) {
// restmaxの1問あたりの点数
int ptrmx = 100 * (restmax + 1);
int neednum = (G - pt + ptrmx - 1) / ptrmx;
//必要な問題数がp[restmax]を超えてしまったらその0100...はボツ
if (neednum > plst[restmax]) {
continue;
}
num += neednum;
}
ans = Math.Min(ans, num);
}
Console.WriteLine(ans);
return;
}
public static int Dfs(int p, int D, List<int> plst, List<int> clst,
List<int> RestDlst, int N, int G, List<int> Dmemolst) {
if (p >= G) {
return N;
}
if (Dmemolst[D - 1] + p < G) {
p = p + Dmemolst[D - 1];
N += plst[D - 1];
} else {
for (int i = 0; i < plst[D - 1]; i++) {
p = p + 100 * D;
N++;
if (p >= G) {
return N;
}
}
p += clst[D - 1];
}
if (p >= G) {
return N;
}
var anslst = new List<int>();
foreach (int item in RestDlst) {
var tmpRDlst = new List<int>(RestDlst);
tmpRDlst.Remove(item);
anslst.Add(Dfs(p, item, plst, clst, tmpRDlst, N, G, Dmemolst));
}
return anslst.Min();
}
public static long Gcd(long a, long b) {
long tmp;
// a<bにする
if (a >= b) {
tmp = a;
a = b;
b = tmp;
}
if (a == 0) {
return b;
}
tmp = a;
a = b % a;
b = tmp;
return Gcd(a, b);
}
public static IEnumerable<long> PF(long n) {
long i = 2;
long tmp = n;
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp; //最後の素数も返す
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC104C {
static class MainClass {
public static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
int D = int.Parse(input1[0]);
int G = int.Parse(input1[1]);
var plst = new List<int>();
var clst = new List<int>();
var RestDlst = new List<int>();
var Dmemolst = new List<int>();
int p = 0;
int c = 0;
for (int i = 0; i < D; i++) {
string[] input2 = Console.ReadLine().Split(' ');
p = int.Parse(input2[0]);
c = int.Parse(input2[1]);
plst.Add(p);
clst.Add(c);
RestDlst.Add(i + 1);
Dmemolst.Add(p * (i + 1) * 100 + c);
}
int ans = 1000000000;
for (int mask = 0; mask < (1 << D); mask++) {
int pt = 0, restmax = -1, num = 0;
//その0101...でのptを計算
for (int i = 0; i < D; i++) {
// Console.WriteLine("mask: " + mask.ToString() + " maskbit: " +
// (mask>>1).ToString());
if (((mask >> i) & 1) == 1) {
pt += 100 * (i + 1) * plst[i] + clst[i];
num += plst[i];
} else {
restmax = i;
}
}
// Gに達していなければ、restmaxを中途半端に解く
if (pt < G) {
// restmaxの1問あたりの点数
int ptrmx = 100 * (restmax + 1);
int neednum = (G - pt + ptrmx - 1) / ptrmx;
//必要な問題数がp[restmax]を超えてしまったらその0100...はボツ
if (neednum > plst[restmax]) {
continue;
}
num += neednum;
}
ans = Math.Min(ans, num);
}
Console.WriteLine(ans);
return;
}
public static int Dfs(int p, int D, List<int> plst, List<int> clst,
List<int> RestDlst, int N, int G, List<int> Dmemolst) {
if (p >= G) {
return N;
}
if (Dmemolst[D - 1] + p < G) {
p = p + Dmemolst[D - 1];
N += plst[D - 1];
} else {
for (int i = 0; i < plst[D - 1]; i++) {
p = p + 100 * D;
N++;
if (p >= G) {
return N;
}
}
p += clst[D - 1];
}
if (p >= G) {
return N;
}
var anslst = new List<int>();
foreach (int item in RestDlst) {
var tmpRDlst = new List<int>(RestDlst);
tmpRDlst.Remove(item);
anslst.Add(Dfs(p, item, plst, clst, tmpRDlst, N, G, Dmemolst));
}
return anslst.Min();
}
public static long Gcd(long a, long b) {
long tmp;
// a<bにする
if (a >= b) {
tmp = a;
a = b;
b = tmp;
}
if (a == 0) {
return b;
}
tmp = a;
a = b % a;
b = tmp;
return Gcd(a, b);
}
public static IEnumerable<long> PF(long n) {
long i = 2;
long tmp = n;
while (i * i <= n) //※1
{
if (tmp % i == 0) {
tmp /= i;
yield return i;
} else {
i++;
}
}
if (tmp != 1)
yield return tmp; //最後の素数も返す
}
}
}
|
[["+", 15, 16, 31, 23, 0, 16, 31, 23, 0, 24], ["+", 15, 16, 31, 23, 0, 16, 31, 23, 0, 25], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 67], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 12, 203]]
| 8
| 772
| 4
|
using System;
using System.Linq;
public class Hello {
public static int D;
public static int G;
public static int[] S;
public static int score = 0;
public static int count = 0;
public static void Main() {
//入力受け取り
int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
D = a[0];
G = a[1];
int[] p = new int[10];
int[] c = new int[10];
S = new int[D];
int ans = 1000;
for (int i = 0; i < D; i++) {
int[] b =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
p[i] = b[0];
c[i] = b[1];
}
//ビット全探索
for (int mask = 0; mask < (1 << D); mask++) {
int S = 0;
int num = 0;
int need = 0;
int rest_max = -1;
for (int i = 0; i < D; i++) {
if ((mask >> i) == 1) {
S += 100 * (i + 1) * p[i] + c[i];
num += p[i];
} else {
rest_max = i;
}
}
if (S < G) //目標点に届かない場合
{
int S1 = 100 * (rest_max + 1);
need = (G - S + S1 - 1) / S1; //中途半端に解かなければならない問題数
if (need >= p[rest_max]) {
continue;
} else {
num += need;
}
}
//最小値の更新
ans = Math.Min(ans, num);
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
public class Hello {
public static int D;
public static int G;
public static int[] S;
public static int score = 0;
public static int count = 0;
public static void Main() {
//入力受け取り
int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
D = a[0];
G = a[1];
int[] p = new int[10];
int[] c = new int[10];
S = new int[D];
int ans = 1000;
for (int i = 0; i < D; i++) {
int[] b =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
p[i] = b[0];
c[i] = b[1];
}
//ビット全探索
for (int mask = 0; mask < (1 << D); mask++) {
int S = 0;
int num = 0;
int need = 0;
int rest_max = -1;
for (int i = 0; i < D; i++) {
if ((mask >> i & 1) == 1) {
S += 100 * (i + 1) * p[i] + c[i];
num += p[i];
} else {
rest_max = i;
}
}
if (S < G) //目標点に届かない場合
{
int S1 = 100 * (rest_max + 1);
need = (G - S + S1 - 1) / S1; //中途半端に解かなければならない問題数
if (need >= p[rest_max]) {
continue;
} else {
num += need;
}
}
//最小値の更新
ans = Math.Min(ans, num);
}
Console.WriteLine(ans);
}
}
|
[["+", 0, 57, 15, 16, 31, 23, 0, 16, 17, 67], ["+", 0, 57, 15, 16, 31, 23, 0, 16, 12, 203]]
| 8
| 384
| 2
|
using System.Collections.Generic;
using System.Linq;
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var g = int.Parse(line[1]);
var a = new int[n, 2];
for (int i = 0; i < n; i++) {
line = Console.ReadLine().Trim().Split(' ');
a[i, 0] = int.Parse(line[0]);
a[i, 1] = int.Parse(line[1]);
}
var ans = new List<int>();
var imax = 1 << 5;
for (int i = 0; i < imax; i++) {
var used = new bool[n];
var p = 0;
var count = 0;
for (int j = 0; j < n; j++) {
if (((i >> j) & 1) == 1) {
used[j] = true;
p += ((j + 1) * 100 * a[j, 0] + a[j, 1]);
count += a[j, 0];
}
}
if (p >= g) {
ans.Add(count);
continue;
} else {
var diff = g - p;
for (int j = n - 1; j >= 0; j--) {
if (!used[j]) {
var pc = (diff + (j + 1) * 100 - 1) / ((j + 1) * 100);
if (pc < a[j, 0])
ans.Add(count + pc);
break;
}
}
}
}
Console.WriteLine(ans.Min());
}
}
|
using System.Collections.Generic;
using System.Linq;
using System;
public class Hello {
public static void Main() {
string[] line = Console.ReadLine().Trim().Split(' ');
var n = int.Parse(line[0]);
var g = int.Parse(line[1]);
var a = new int[n, 2];
for (int i = 0; i < n; i++) {
line = Console.ReadLine().Trim().Split(' ');
a[i, 0] = int.Parse(line[0]);
a[i, 1] = int.Parse(line[1]);
}
var ans = new List<int>();
var imax = 1 << n;
for (int i = 0; i < imax; i++) {
var used = new bool[n];
var p = 0;
var count = 0;
for (int j = 0; j < n; j++) {
if (((i >> j) & 1) == 1) {
used[j] = true;
p += ((j + 1) * 100 * a[j, 0] + a[j, 1]);
count += a[j, 0];
}
}
if (p >= g)
ans.Add(count);
else {
var diff = g - p;
for (int j = n - 1; j >= 0; j--) {
if (!used[j]) {
var pc = (diff + (j + 1) * 100 - 1) / ((j + 1) * 100);
if (pc < a[j, 0])
ans.Add(count + pc);
break;
}
}
}
}
Console.WriteLine(ans.Min());
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["-", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 8, 196, 0, 57, 64, 196, 0, 116, 0, 117], ["-", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 398
| 6
|
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() {
long min = (long)1e9;
for (int i = 0; i < (1 << D); i++) {
long sc = 0;
long cnt = 0;
for (int j = 0; j < D; j++) {
if (((i >> j) & 1) == 0)
continue;
sc += C[j];
sc += 100 * (j + 1) * P[j];
cnt += P[j];
}
if (sc > G) {
min = Math.Min(cnt, min);
continue;
}
for (int j = D - 1; j >= 0; j--) {
if (((i >> j) & 1) == 1)
continue;
if (P[j] == 1)
continue;
if ((j + 1) * (P[j] - 1) * 100 + sc < G) {
sc += (j + 1) * 100 * (P[j] - 1);
cnt += (P[j] - 1);
continue;
} else {
long u = 100 * (j + 1);
cnt += (G - sc + u - 1) / u;
min = Math.Min(cnt, min);
break;
}
}
}
Console.WriteLine(min);
}
int D;
long G;
long[] P, C;
public Sol() {
var d = rla();
D = (int)d[0];
G = d[1];
P = new long[D];
C = new long[D];
for (int i = 0; i < D; i++) {
d = rla();
P[i] = d[0];
C[i] = 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() {
long min = (long)1e9;
for (int i = 0; i < (1 << D); i++) {
long sc = 0;
long cnt = 0;
for (int j = 0; j < D; j++) {
if (((i >> j) & 1) == 0)
continue;
sc += C[j];
sc += 100 * (j + 1) * P[j];
cnt += P[j];
}
if (sc >= G) {
min = Math.Min(cnt, min);
continue;
}
for (int j = D - 1; j >= 0; j--) {
if (((i >> j) & 1) == 1)
continue;
if (P[j] == 1)
continue;
if ((j + 1) * (P[j] - 1) * 100 + sc < G) {
sc += (j + 1) * 100 * (P[j] - 1);
cnt += (P[j] - 1);
continue;
} else {
long u = 100 * (j + 1);
cnt += (G - sc + u - 1) / u;
min = Math.Min(cnt, min);
break;
}
}
}
Console.WriteLine(min);
}
int D;
long G;
long[] P, C;
public Sol() {
var d = rla();
D = (int)d[0];
G = d[1];
P = new long[D];
C = new long[D];
for (int i = 0; i < D; i++) {
d = rla();
P[i] = d[0];
C[i] = 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, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20]]
| 8
| 653
| 2
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
internal partial class Solver {
public void Run() {
var s = ns();
var mod = 1000000000 + 7;
long A = 0;
long AB = 0;
long ABC = 0;
int pattern = 1;
foreach (var c in s) {
var nA = A;
var nAB = AB;
var nABC = ABC;
// A?
// AA, AB, AC
// ?A
// AA, BA, CA
if (c == 'A' || c == '?') {
nA += pattern;
}
if (c == 'B' || c == '?') {
nAB += A;
}
if (c == 'C' || c == '?') {
nABC += AB;
}
if (c == '?') {
nA += 2 * A;
nAB += 2 * AB;
nABC += 2 * ABC;
pattern *= 3;
pattern %= mod;
}
// cout.WriteLine($"{c} : { nA } { nAB} { nABC}");
A = nA % mod;
AB = nAB % mod;
ABC = nABC % mod;
}
cout.WriteLine(ABC);
}
}
// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
public static void Main(string[] args) {
#if LOCAL
new Solver(Console.In, Console.Out).Run();
#else
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver(Console.In, Console.Out).Run();
Console.Out.Flush();
#endif
}
public void RunMulti() {
while (HasNext()) {
Run();
}
}
#pragma warning disable IDE0052
private readonly TextReader cin;
private readonly TextWriter cout;
#pragma warning restore IDE0052
public Solver(TextReader reader, TextWriter writer) : base(reader) {
cin = reader;
cout = writer;
}
public Solver(string input, TextWriter writer)
: this(new StringReader(input), writer) {}
#pragma warning disable IDE1006
#pragma warning disable IDE0051
private int ni() { return NextInt(); }
private int[] ni(int n) { return NextIntArray(n); }
private long nl() { return NextLong(); }
private long[] nl(int n) { return NextLongArray(n); }
private double nd() { return NextDouble(); }
private double[] nd(int n) { return NextDoubleArray(n); }
private string ns() { return Next(); }
private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}
public static class LinqPadExtension {
public static T Dump<T>(this T obj) {
#if LOCAL
return LINQPad.Extensions.Dump(obj);
#else
return obj;
#endif
}
}
public class Scanner {
private readonly TextReader Reader;
private readonly Queue<string> TokenQueue = new Queue<string>();
private readonly CultureInfo ci = CultureInfo.InvariantCulture;
public Scanner() : this(Console.In) {}
public Scanner(TextReader reader) { Reader = reader; }
public int NextInt() { return int.Parse(Next(), ci); }
public long NextLong() { return long.Parse(Next(), ci); }
public double NextDouble() { return double.Parse(Next(), ci); }
public string[] NextArray(int size) {
var array = new string[size];
for (var i = 0; i < size; i++) {
array[i] = Next();
}
return array;
}
public int[] NextIntArray(int size) {
var array = new int[size];
for (var i = 0; i < size; i++) {
array[i] = NextInt();
}
return array;
}
public long[] NextLongArray(int size) {
var array = new long[size];
for (var i = 0; i < size; i++) {
array[i] = NextLong();
}
return array;
}
public double[] NextDoubleArray(int size) {
var array = new double[size];
for (var i = 0; i < size; i++) {
array[i] = NextDouble();
}
return array;
}
public string Next() {
if (TokenQueue.Count == 0) {
if (!StockTokens()) {
throw new InvalidOperationException();
}
}
return TokenQueue.Dequeue();
}
public bool HasNext() {
if (TokenQueue.Count > 0) {
return true;
}
return StockTokens();
}
private static readonly char[] _separator = new[] { ' ', '\t' };
private bool StockTokens() {
while (true) {
var line = Reader.ReadLine();
if (line == null) {
return false;
}
var tokens =
line.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length == 0) {
continue;
}
foreach (var token in tokens) {
TokenQueue.Enqueue(token);
}
return true;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
internal partial class Solver {
public void Run() {
var s = ns();
var mod = 1000000000 + 7;
long A = 0;
long AB = 0;
long ABC = 0;
long pattern = 1;
foreach (var c in s) {
var nA = A;
var nAB = AB;
var nABC = ABC;
// A?
// AA, AB, AC
// ?A
// AA, BA, CA
if (c == 'A' || c == '?') {
nA += pattern;
}
if (c == 'B' || c == '?') {
nAB += A;
}
if (c == 'C' || c == '?') {
nABC += AB;
}
if (c == '?') {
nA += 2 * A;
nAB += 2 * AB;
nABC += 2 * ABC;
pattern *= 3;
pattern %= mod;
}
// cout.WriteLine($"{c} : { nA } { nAB} { nABC}");
A = nA % mod;
AB = nAB % mod;
ABC = nABC % mod;
}
cout.WriteLine(ABC);
}
}
// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
public static void Main(string[] args) {
#if LOCAL
new Solver(Console.In, Console.Out).Run();
#else
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver(Console.In, Console.Out).Run();
Console.Out.Flush();
#endif
}
public void RunMulti() {
while (HasNext()) {
Run();
}
}
#pragma warning disable IDE0052
private readonly TextReader cin;
private readonly TextWriter cout;
#pragma warning restore IDE0052
public Solver(TextReader reader, TextWriter writer) : base(reader) {
cin = reader;
cout = writer;
}
public Solver(string input, TextWriter writer)
: this(new StringReader(input), writer) {}
#pragma warning disable IDE1006
#pragma warning disable IDE0051
private int ni() { return NextInt(); }
private int[] ni(int n) { return NextIntArray(n); }
private long nl() { return NextLong(); }
private long[] nl(int n) { return NextLongArray(n); }
private double nd() { return NextDouble(); }
private double[] nd(int n) { return NextDoubleArray(n); }
private string ns() { return Next(); }
private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}
public static class LinqPadExtension {
public static T Dump<T>(this T obj) {
#if LOCAL
return LINQPad.Extensions.Dump(obj);
#else
return obj;
#endif
}
}
public class Scanner {
private readonly TextReader Reader;
private readonly Queue<string> TokenQueue = new Queue<string>();
private readonly CultureInfo ci = CultureInfo.InvariantCulture;
public Scanner() : this(Console.In) {}
public Scanner(TextReader reader) { Reader = reader; }
public int NextInt() { return int.Parse(Next(), ci); }
public long NextLong() { return long.Parse(Next(), ci); }
public double NextDouble() { return double.Parse(Next(), ci); }
public string[] NextArray(int size) {
var array = new string[size];
for (var i = 0; i < size; i++) {
array[i] = Next();
}
return array;
}
public int[] NextIntArray(int size) {
var array = new int[size];
for (var i = 0; i < size; i++) {
array[i] = NextInt();
}
return array;
}
public long[] NextLongArray(int size) {
var array = new long[size];
for (var i = 0; i < size; i++) {
array[i] = NextLong();
}
return array;
}
public double[] NextDoubleArray(int size) {
var array = new double[size];
for (var i = 0; i < size; i++) {
array[i] = NextDouble();
}
return array;
}
public string Next() {
if (TokenQueue.Count == 0) {
if (!StockTokens()) {
throw new InvalidOperationException();
}
}
return TokenQueue.Dequeue();
}
public bool HasNext() {
if (TokenQueue.Count > 0) {
return true;
}
return StockTokens();
}
private static readonly char[] _separator = new[] { ' ', '\t' };
private bool StockTokens() {
while (true) {
var line = Reader.ReadLine();
if (line == null) {
return false;
}
var tokens =
line.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length == 0) {
continue;
}
foreach (var token in tokens) {
TokenQueue.Enqueue(token);
}
return true;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 1,043
| 2
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
// Console.WriteLine("Hello World!");
var a = Console.ReadLine()
.Split()
.Select(int.Parse)
.OrderByDescending(x => -x)
.ToArray();
Console.WriteLine(a[0] + a[2]);
}
}
}
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var a =
Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();
Console.WriteLine(a[2] - a[0]);
}
}
}
|
[["-", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 3, 4, 0, 28, 0, 218, 8, 241, 0, 33], ["-", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 31, 204, 206, 207, 0, 28, 0, 203], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33], ["-", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 16, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 75
| 9
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
void calc() {
cin = new Scanner();
cin2 = new Func();
int[] A = cin.ArrayInt(2, 0);
Array.Sort(A);
Console.WriteLine(A[2] - A[0]);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Answer {
public static void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
} // Answer.IntArrayAns(x);
public static void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
Func cin2;
void calc() {
cin = new Scanner();
cin2 = new Func();
int[] A = cin.ArrayInt(3, 0);
Array.Sort(A);
Console.WriteLine(A[2] - A[0]);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
class Answer {
public static void Int2DArrayAns(int[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
} // Answer.IntArrayAns(x);
public static void Char2DArrayAns(char[,] x, char c) {
for (int i = 0; i < x.GetLength(0); i++) {
for (int j = 0; j < x.GetLength(1) - 1; j++) {
Console.Write(x[i, j]);
Console.Write(c);
}
Console.WriteLine(x[i, x.GetLength(1) - 1]);
}
}
}
class Func {
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
[["-", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 212, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 722
| 2
|
using System;
using System.Linq;
public class Program {
public static void Main() {
var arr = ReadLib.ReadAsIntArray();
var sub = new int[] { arr[0] - arr[1], arr[1] - arr[2], arr[2] - arr[0] };
var abs =
sub.Select(s => Math.Abs(2)).OrderByDescending(i => i).Skip(1).Sum();
Console.WriteLine(abs);
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray() {
return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
}
|
using System;
using System.Linq;
public class Program {
public static void Main() {
var arr = ReadLib.ReadAsIntArray();
var sub = new int[] { arr[0] - arr[1], arr[1] - arr[2], arr[2] - arr[0] };
var abs =
sub.Select(s => Math.Abs(s)).OrderByDescending(i => i).Skip(1).Sum();
Console.WriteLine(abs);
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray() {
return Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
}
}
|
[["-", 0, 218, 8, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 218, 8, 213, 3, 4, 0, 28, 0, 22]]
| 8
| 194
| 2
|
using System;
namespace B___String_Rotation {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var t = Console.ReadLine();
for (var i = 0; i < s.Length - 1; i++) {
if (s == t) {
Console.WriteLine("Yes");
return;
}
s = s[s.Length - 1] + s.Substring(0, s.Length - 1);
}
Console.WriteLine("No");
}
}
}
|
using System;
namespace B___String_Rotation {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var t = Console.ReadLine();
for (var i = 0; i < s.Length; i++) {
if (s == t) {
Console.WriteLine("Yes");
return;
}
s = s[s.Length - 1] + s.Substring(0, s.Length - 1);
}
Console.WriteLine("No");
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 112
| 2
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var T = Console.ReadLine();
for (var i = 0; i < S.Length; i++) {
S = S[S.Length - 1].ToString() + S.Remove(S.Length - 2);
if (S.SequenceEqual(T)) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
var S = Console.ReadLine();
var T = Console.ReadLine();
for (var i = 0; i < S.Length; i++) {
S = S[S.Length - 1].ToString() + S.Remove(S.Length - 1);
if (S.SequenceEqual(T)) {
Console.WriteLine("Yes");
return;
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 120
| 2
|
using System;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) { MainStream(); }
static void MainStream() {
char[] s = Console.ReadLine().ToCharArray();
char[] t = Console.ReadLine().ToCharArray();
if (Judge(s, t)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
static bool Judge(char[] list1, char[] list2) {
for (int i = 0; i < list1.Length; i++) {
if (!ArrayJudge(list1, list2)) {
return true;
}
char tmp = list1[0];
for (int j = 0; j < list1.Length - 1; j++) {
list1[j] = list1[j + 1];
}
list1[list1.Length - 1] = tmp;
}
return false;
}
static bool ArrayJudge(char[] list1, char[] list2) {
for (int i = 0; i < list1.Length; i++) {
if (list1[i] != list2[i]) {
return false;
}
}
return true;
}
}
}
|
using System;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) { MainStream(); }
static void MainStream() {
char[] s = Console.ReadLine().ToCharArray();
char[] t = Console.ReadLine().ToCharArray();
if (Judge(s, t)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
static bool Judge(char[] list1, char[] list2) {
for (int i = 0; i < list1.Length; i++) {
if (ArrayJudge(list1, list2)) {
return true;
}
char tmp = list1[0];
for (int j = 0; j < list1.Length - 1; j++) {
list1[j] = list1[j + 1];
}
list1[list1.Length - 1] = tmp;
}
return false;
}
static bool ArrayJudge(char[] list1, char[] list2) {
for (int i = 0; i < list1.Length; i++) {
if (list1[i] != list2[i]) {
return false;
}
}
return true;
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 241, 0, 111]]
| 8
| 257
| 1
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc103_b {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var t = Console.ReadLine();
for (int i = 0; i < s.Length; i++) {
if (s == t) {
WriteLine("Yes");
return;
} else {
var tmp = s.Remove(0, 1);
s = tmp + s[0];
WriteLine(s);
}
}
WriteLine("No");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc103_b {
class Program {
static void Main(string[] args) {
var s = Console.ReadLine();
var t = Console.ReadLine();
for (int i = 0; i < s.Length; i++) {
if (s == t) {
WriteLine("Yes");
return;
} else {
var tmp = s.Remove(0, 1);
s = tmp + s[0];
}
}
WriteLine("No");
}
}
}
|
[["-", 0, 57, 75, 196, 0, 1, 0, 213, 63, 22], ["-", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 22], ["-", 75, 196, 0, 1, 0, 213, 3, 4, 0, 25], ["-", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 160
| 5
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtcoderTemplateForCSharp {
public class Program {
public static void Main(string[] args) {
var s = Console.ReadLine();
var w = Console.ReadLine().Select(x => int.Parse(x.ToString())).First();
for (int i = 0; i < s.Length; i++) {
if ((i) % w == 0) {
Console.Write(s[i]);
}
}
Console.WriteLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtcoderTemplateForCSharp {
public class Program {
public static void Main(string[] args) {
var s = Console.ReadLine();
var w =
Console.ReadLine().Split().Select(x => int.Parse(x.ToString())).First();
for (int i = 0; i < s.Length; i++) {
if ((i + w) % w == 0) {
Console.Write(s[i]);
}
}
Console.WriteLine();
}
}
}
|
[["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 15, 16, 31, 16, 31, 23, 0, 16, 12, 22]]
| 8
| 132
| 6
|
using System;
using System.Collections.Generic;
using System.Text;
class Solution {
static void Main() {
var s = Console.ReadLine();
var w = int.Parse(Console.ReadLine());
var buff = new StringBuilder();
for (int i = 0; i < s.Length; i += 3) {
buff.Append(s[i]);
}
Console.WriteLine(buff);
}
}
|
using System;
using System.Collections.Generic;
using System.Text;
class Solution {
static void Main() {
var s = Console.ReadLine();
var w = int.Parse(Console.ReadLine());
var buff = new StringBuilder();
for (int i = 0; i < s.Length; i += w) {
buff.Append(s[i]);
}
Console.WriteLine(buff);
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 26, 11, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 26, 11, 12, 22]]
| 8
| 93
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Solve {
static public int mod = 1000000007;
static public string al = "abcdefghijklmnopqrstuvwxyz";
public static void Main() {
// 方針
//
var ds = doublea();
var n = ds[0];
var m = ds[1];
var d = ds[2];
if (d == 0) {
WriteLine(1 / n * (m - 1));
} else if (0 < d && d < n / 2) {
WriteLine(((n - d) * 2) / n * (m - 1));
} else {
WriteLine((n - d) / n * (m - 1));
}
}
public static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
if (n < r)
return 0;
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static int square2(int a, int b) {
long output = 1;
var list = new List<long>();
int sh = 1;
long n = a;
list.Add(a);
while (sh < b) {
sh *= 2;
n = n * n % mod;
list.Add(n);
}
for (int i = list.Count - 1; i >= 0; i--) {
if (b > sh) {
b -= sh;
sh /= 2;
output = output * list[i] % mod;
}
}
return (int)output;
}
//各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;
public class Solve {
static public int mod = 1000000007;
static public string al = "abcdefghijklmnopqrstuvwxyz";
public static void Main() {
// 方針
//
var ds = doublea();
var n = ds[0];
var m = ds[1];
var d = ds[2];
if (d == 0) {
WriteLine(1 / n * (m - 1));
} else if (0 < d && d < n / 2) {
WriteLine(((n - d) * 2) / (n * n) * (m - 1));
} else {
WriteLine((n - d) / n * (m - 1));
}
}
public static void swap(ref int a, ref int b) {
int temp = a;
a = b;
b = temp;
}
static void charswap(ref char a, ref char b) {
char temp = a;
a = b;
b = temp;
}
static int ncr(int n, int r) {
if (n < r)
return 0;
r = Min(r, n - r);
long nn = 1;
for (int i = n - r + 1; i <= n; i++) {
nn = nn * i % mod;
}
long rr = 1;
for (int i = 1; i <= r; i++) {
rr = rr * i % mod;
}
rr = square((int)rr, mod - 2);
nn = nn * rr % mod;
return (int)nn;
}
// a^b mod
static int square(int a, int b) {
string binary = Convert.ToString(b, 2);
int bileng = binary.Length;
long a_power = a;
long value = 1;
for (int i = bileng - 1; i >= 0; i--) {
if (binary[i] == '1') {
value = value * a_power % mod;
}
a_power = a_power * a_power % mod;
}
return (int)value;
}
static int square2(int a, int b) {
long output = 1;
var list = new List<long>();
int sh = 1;
long n = a;
list.Add(a);
while (sh < b) {
sh *= 2;
n = n * n % mod;
list.Add(n);
}
for (int i = list.Count - 1; i >= 0; i--) {
if (b > sh) {
b -= sh;
sh /= 2;
output = output * list[i] % mod;
}
}
return (int)output;
}
//各種読取
static string rstr() { return ReadLine(); }
static int rint() { return int.Parse(ReadLine()); }
static long rlong() { return long.Parse(ReadLine()); }
static string[] stra() { return ReadLine().Split(' '); }
static char[] chara() {
string[] a = stra();
string b = "";
for (int i = 0; i < a.Length; i++) {
b += a[i];
}
return b.ToCharArray();
}
static int[] inta() {
string[] read_str_array = ReadLine().Split(' ');
int[] return_int_array = new int[read_str_array.Length];
for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
}
return return_int_array;
}
static int[,] inta2(int num_array, int in_array) {
int[,] int_array2 = new int[num_array, in_array];
for (int i = 0; i < num_array; i++) {
int[] temp_array = inta();
for (int j = 0; j < in_array; j++) {
int_array2[i, j] = temp_array[j];
}
}
return int_array2;
}
static long[] longa() {
string[] read_str_array = ReadLine().Split(' ');
long[] return_long_array = new long[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_long_array[countup_i] = long.Parse(read_str_array[countup_i]);
}
return return_long_array;
}
static double[] doublea() {
string[] read_str_array = ReadLine().Split(' ');
double[] return_double_array = new double[read_str_array.Length];
for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) {
return_double_array[countup_i] = double.Parse(read_str_array[countup_i]);
}
return return_double_array;
}
// -----------------------------
static long divideup(long divided, long divid) {
long temp_divide = divided / divid;
if (divided % divid > 0) {
temp_divide++;
}
return temp_divide;
}
static long GCD(long a, long b) {
if (a < b) {
long temp = a;
a = b;
b = temp;
}
if (a % b == 0) {
return b;
} else {
long temp = b;
b = a % b;
a = temp;
return GCD(a, b);
}
}
static long LCM(long a, long b) { return a * b / GCD(a, b); }
static void WriteArray(int[,] a, int b, int c) {
for (int i = 0; i < b; i++) {
for (int j = 0; j < c; j++) {
if (j != 0)
Write(" ");
Write(a[i, j]);
}
WriteLine();
}
}
}
|
[["+", 0, 28, 0, 16, 31, 16, 12, 23, 0, 24], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 16, 31, 16, 12, 23, 0, 16, 17, 48], ["+", 0, 28, 0, 16, 31, 16, 12, 23, 0, 25]]
| 8
| 1,213
| 4
|
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 = Longs;
var n = o[0];
var m = o[1];
var d = o[2];
if (d == 0) {
Write((double)(m - 1) / (double)n);
} else {
double x = 2 * (m - 1) * (n - 1);
Write(x / n / n);
}
}
}
public class Factorical {
public long[] Fact;
public long[] invFact;
public Factorical(long N, long MOD = 1000000007) {
Fact = new long[N + 1];
invFact = new long[N + 1];
Fact[0] = 1;
for (long i = 1; i <= N; ++i) {
Fact[i] = Fact[i - 1] * i % MOD;
}
invFact[N] = Power(Fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invFact[i - 1] = invFact[i] * i % MOD;
}
}
public long Comb(long n, long r,
long MOD = 1000000007) => Fact[n] * invFact[r] % MOD
* invFact[n - r] % MOD;
}
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 a, long b, long MOD = 1000000007) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
public static long Power2(long a, long b) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
public static long GCD(long a, long b) {
while (b > 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long LCM(long a, long b) => (b / GCD(a, b)) * a;
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)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno *= i;
Nume *= n - i + 1;
}
return Nume / Deno;
}
}
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 = Longs;
var n = o[0];
var m = o[1];
var d = o[2];
if (d == 0) {
Write((double)(m - 1) / (double)n);
} else {
double x = 2 * (m - 1) * (n - d);
Write(x / n / n);
}
}
}
public class Factorical {
public long[] Fact;
public long[] invFact;
public Factorical(long N, long MOD = 1000000007) {
Fact = new long[N + 1];
invFact = new long[N + 1];
Fact[0] = 1;
for (long i = 1; i <= N; ++i) {
Fact[i] = Fact[i - 1] * i % MOD;
}
invFact[N] = Power(Fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invFact[i - 1] = invFact[i] * i % MOD;
}
}
public long Comb(long n, long r,
long MOD = 1000000007) => Fact[n] * invFact[r] % MOD
* invFact[n - r] % MOD;
}
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 a, long b, long MOD = 1000000007) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a % MOD;
a = a * a % MOD;
b >>= 1;
}
return res;
}
public static long Power2(long a, long b) // i^N
{
long res = 1;
while (b > 0) {
if ((b & 1) != 0)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
public static long GCD(long a, long b) {
while (b > 0) {
var r = a % b;
a = b;
b = r;
}
return a;
}
public static long LCM(long a, long b) => (b / GCD(a, b)) * a;
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)
r = n - r;
for (long i = 1; i <= r; ++i) {
Deno *= i;
Nume *= n - i + 1;
}
return Nume / Deno;
}
}
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");
}
}
|
[["-", 0, 212, 0, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 212, 0, 16, 12, 23, 0, 16, 12, 22]]
| 8
| 1,122
| 2
|
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 nmd = Input.ar;
var p = nmd[2] == 0 ? (double)1 / nmd[0]
: (double)2 * (nmd[0] - nmd[2]) / (nmd[0] * nmd[0]);
WriteLine(p * (nmd[1] - 1));
}
}
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 const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
|
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 nmd = Input.ar;
var p = nmd[2] == 0
? (double)1 / nmd[0]
: (double)2 * (nmd[0] - nmd[2]) / ((long)nmd[0] * nmd[0]);
WriteLine(p * (nmd[1] - 1));
}
}
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 const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
|
[["+", 75, 16, 12, 23, 0, 16, 31, 74, 0, 24], ["+", 75, 16, 12, 23, 0, 16, 31, 74, 39, 199], ["+", 75, 16, 12, 23, 0, 16, 31, 74, 0, 25]]
| 8
| 219
| 3
|
using System;
using System.Collections.Generic;
namespace AtCoder.Company.SoundHound {
class c {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var spl = line.Split(' ');
var n = double.Parse(spl[0]);
var m = double.Parse(spl[1]);
var d = double.Parse(spl[2]);
if (n == 0) {
Console.WriteLine((m - 1) / n);
} else {
Console.WriteLine(2 * (n - d) / n * (m - 1) / n);
}
}
}
}
|
using System;
using System.Collections.Generic;
namespace AtCoder.Company.SoundHound {
class c {
static void Main(string[] args) {
var line = Console.ReadLine().Trim();
var spl = line.Split(' ');
var n = double.Parse(spl[0]);
var m = double.Parse(spl[1]);
var d = double.Parse(spl[2]);
if (d == 0) {
Console.WriteLine((m - 1) / n);
} else {
Console.WriteLine(2 * (n - d) / n * (m - 1) / n);
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 144
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;
using Number = System.Int64;
class Solver {
public void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kedge = new Dijkstra(num);
var yedge = new Dijkstra(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kedge.AddEdge(a, b, k);
kedge.AddEdge(b, a, k);
yedge.AddEdge(a, b, y);
yedge.AddEdge(b, a, y);
}
var kdist = kedge.Execute(t);
var ydist = yedge.Execute(s);
var inf = (long)1e15;
var res = new long[num];
var min = 0L;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
}
class Dijkstra {
private int num;
private List<Edge>[] edges;
public Dijkstra(int num) {
this.num = num;
edges = Create(num, () => new List<Edge>());
}
public void AddEdge(int from, int to,
Number weight) => edges[from].Add(new Edge(to, weight));
public Number[] Execute(int st = 0) {
var dist = Create(num, () => Number.MaxValue);
var pq = new Binary_Heap<Number>(num);
pq.Prioritize(0, st);
dist[st] = 0;
while (pq.Any()) {
var p = pq.Pop();
if (p.v1 > dist[p.v2])
continue;
foreach (var e in edges[p.v2])
if (chmin(ref dist[e.to], e.cost + p.v2))
pq.Prioritize(dist[e.to], e.to);
}
return dist;
}
struct Edge : IComparable<Edge> {
public int to;
public Number cost;
public Edge(int to, Number cost) {
this.to = to;
this.cost = cost;
}
public int CompareTo(Edge e) => cost.CompareTo(e.cost);
}
}
public class Binary_Heap<T> {
private Pair<T, int>[] item;
private int[] rev;
private Comparison<T> cmp;
public int Count { get; private set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public bool
Any() => Count > 0;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Parent(int i) => (i - 1) >> 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Left(int i) => (i << 1) + 1;
public Binary_Heap(int num) {
item = new Pair<T, int>[num];
rev = Create(num, () => -1);
cmp = Comparer<T>.Default.Compare;
}
public Binary_Heap(int num, Comparison<T> comparison) : this(num) {
cmp = comparison;
}
public Binary_Heap(int num, IComparer<T> comparer) : this(num) {
cmp = comparer.Compare;
}
private void Push(T v, int index) {
int i = Count;
item[Count] = new Pair<T, int>(v, index);
rev[index] = i;
while (i > 0) {
int p = Parent(i);
if (cmp(item[p].v1, v) <= 0)
break;
swap(ref item[i], ref item[p]);
swap(ref rev[item[i].v2], ref rev[item[p].v2]);
i = p;
}
Count++;
}
public Pair<T, int> Pop() {
var ret = item[0];
rev[ret.v2] = -1;
swap(ref item[0], ref item[Count - 1]);
rev[item[0].v2] = 0;
var p = 0;
while (Left(p) < Count - 1) {
var l = Left(p);
if (l < Count - 2 && cmp(item[l + 1].v1, item[l].v1) < 0)
l++;
if (cmp(item[l].v1, item[p].v1) >= 0)
break;
swap(ref item[p], ref item[l]);
swap(ref rev[item[p].v2], ref rev[item[l].v2]);
p = l;
}
Count--;
return ret;
}
public void Prioritize(T v, int index) {
var i = rev[index];
if (i == -1) {
Push(v, index);
return;
}
if (cmp(item[i].v1, v) <= 0)
return;
item[i].v1 = v;
while (i > 0) {
int p = Parent(i);
if (cmp(item[p].v1, v) <= 0)
break;
swap(ref item[i], ref item[p]);
swap(ref rev[item[i].v2], ref rev[item[p].v2]);
i = p;
}
}
}
#region Template
public class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) =>
Enumerable.Repeat(0, n).Select(_ => f()).ToArray();
public static void Fail() => Fail("No");
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new Solver();
for (var i = 1; i > 0; --i)
p.Solve();
Console.Out.Flush();
}
}
public class Input {
public static string read => Console.ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => Convert.ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => Convert.ToInt64(read);
public static char[][] grid(int h) => Create(h, () => read.ToCharArray());
public static int[] ar1D(int n) => Create(n, () => num);
public static long[] arL1D(int n) => Create(n, () => numL);
public static string[] strs(int n) => Create(n, () => read);
public static int[][] ar2D(int n) => Create(n, () => ar);
public static long[][] arL2D(int n) => Create(n, () => arL);
public static List<T>[] edge<T>(int n) => Create(n, () => new List<T>());
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
static Input() {
sc = new Queue<string>();
dic = new Dictionary<Type, Func<string, object>>();
dic[typeof(int)] = s => int.Parse(s);
dic[typeof(long)] = s => long.Parse(s);
dic[typeof(char)] = s => char.Parse(s);
dic[typeof(double)] = s => double.Parse(s);
dic[typeof(uint)] = s => uint.Parse(s);
dic[typeof(ulong)] = s => ulong.Parse(s);
dic[typeof(string)] = s => s;
}
private static Dictionary<Type, Func<string, object>> dic;
private static Queue<string> sc;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Next<T>() {
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return (T)dic[typeof(T)](sc.Dequeue());
}
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {
v1 = default(T1);
v2 = default(T2);
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() { v3 = default(T3); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;
using Number = System.Int64;
class Solver {
public void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kedge = new Dijkstra(num);
var yedge = new Dijkstra(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kedge.AddEdge(a, b, k);
kedge.AddEdge(b, a, k);
yedge.AddEdge(a, b, y);
yedge.AddEdge(b, a, y);
}
var kdist = kedge.Execute(t);
var ydist = yedge.Execute(s);
var inf = (long)1e15;
var res = new long[num];
var min = 0L;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
}
class Dijkstra {
private int num;
private List<Edge>[] edges;
public Dijkstra(int num) {
this.num = num;
edges = Create(num, () => new List<Edge>());
}
public void AddEdge(int from, int to,
Number weight) => edges[from].Add(new Edge(to, weight));
public Number[] Execute(int st = 0) {
var dist = Create(num, () => Number.MaxValue);
var pq = new Binary_Heap<Number>(num);
pq.Prioritize(0, st);
dist[st] = 0;
while (pq.Any()) {
var p = pq.Pop();
if (p.v1 > dist[p.v2])
continue;
foreach (var e in edges[p.v2])
if (chmin(ref dist[e.to], e.cost + p.v1))
pq.Prioritize(dist[e.to], e.to);
}
return dist;
}
struct Edge : IComparable<Edge> {
public int to;
public Number cost;
public Edge(int to, Number cost) {
this.to = to;
this.cost = cost;
}
public int CompareTo(Edge e) => cost.CompareTo(e.cost);
}
}
public class Binary_Heap<T> {
private Pair<T, int>[] item;
private int[] rev;
private Comparison<T> cmp;
public int Count { get; private set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public bool
Any() => Count > 0;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Parent(int i) => (i - 1) >> 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Left(int i) => (i << 1) + 1;
public Binary_Heap(int num) {
item = new Pair<T, int>[num];
rev = Create(num, () => -1);
cmp = Comparer<T>.Default.Compare;
}
public Binary_Heap(int num, Comparison<T> comparison) : this(num) {
cmp = comparison;
}
public Binary_Heap(int num, IComparer<T> comparer) : this(num) {
cmp = comparer.Compare;
}
private void Push(T v, int index) {
int i = Count;
item[Count] = new Pair<T, int>(v, index);
rev[index] = i;
while (i > 0) {
int p = Parent(i);
if (cmp(item[p].v1, v) <= 0)
break;
swap(ref item[i], ref item[p]);
swap(ref rev[item[i].v2], ref rev[item[p].v2]);
i = p;
}
Count++;
}
public Pair<T, int> Pop() {
var ret = item[0];
rev[ret.v2] = -1;
swap(ref item[0], ref item[Count - 1]);
rev[item[0].v2] = 0;
var p = 0;
while (Left(p) < Count - 1) {
var l = Left(p);
if (l < Count - 2 && cmp(item[l + 1].v1, item[l].v1) < 0)
l++;
if (cmp(item[l].v1, item[p].v1) >= 0)
break;
swap(ref item[p], ref item[l]);
swap(ref rev[item[p].v2], ref rev[item[l].v2]);
p = l;
}
Count--;
return ret;
}
public void Prioritize(T v, int index) {
var i = rev[index];
if (i == -1) {
Push(v, index);
return;
}
if (cmp(item[i].v1, v) <= 0)
return;
item[i].v1 = v;
while (i > 0) {
int p = Parent(i);
if (cmp(item[p].v1, v) <= 0)
break;
swap(ref item[i], ref item[p]);
swap(ref rev[item[i].v2], ref rev[item[p].v2]);
i = p;
}
}
}
#region Template
public class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) =>
Enumerable.Repeat(0, n).Select(_ => f()).ToArray();
public static void Fail() => Fail("No");
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new Solver();
for (var i = 1; i > 0; --i)
p.Solve();
Console.Out.Flush();
}
}
public class Input {
public static string read => Console.ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => Convert.ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => Convert.ToInt64(read);
public static char[][] grid(int h) => Create(h, () => read.ToCharArray());
public static int[] ar1D(int n) => Create(n, () => num);
public static long[] arL1D(int n) => Create(n, () => numL);
public static string[] strs(int n) => Create(n, () => read);
public static int[][] ar2D(int n) => Create(n, () => ar);
public static long[][] arL2D(int n) => Create(n, () => arL);
public static List<T>[] edge<T>(int n) => Create(n, () => new List<T>());
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
static Input() {
sc = new Queue<string>();
dic = new Dictionary<Type, Func<string, object>>();
dic[typeof(int)] = s => int.Parse(s);
dic[typeof(long)] = s => long.Parse(s);
dic[typeof(char)] = s => char.Parse(s);
dic[typeof(double)] = s => double.Parse(s);
dic[typeof(uint)] = s => uint.Parse(s);
dic[typeof(ulong)] = s => ulong.Parse(s);
dic[typeof(string)] = s => s;
}
private static Dictionary<Type, Func<string, object>> dic;
private static Queue<string> sc;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Next<T>() {
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return (T)dic[typeof(T)](sc.Dequeue());
}
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {
v1 = default(T1);
v2 = default(T2);
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() { v3 = default(T3); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
#endregion
|
[["-", 3, 4, 0, 28, 0, 16, 12, 214, 141, 22], ["+", 3, 4, 0, 28, 0, 16, 12, 214, 141, 22]]
| 8
| 2,697
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
namespace SolveSpace {
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;
using Number = System.Int64;
class Solver {
public void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kedge = new Dijkstra(num);
var yedge = new Dijkstra(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kedge.AddEdge(a, b, k);
kedge.AddEdge(b, a, k);
yedge.AddEdge(a, b, y);
yedge.AddEdge(b, a, y);
}
var kdist = kedge.Execute(t);
var ydist = kedge.Execute(s);
var inf = (long)1e15;
var res = new long[num];
var min = 0L;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
}
class Dijkstra {
private int num;
private List<Pair<int, Number>>[] edges;
public Dijkstra(int num) {
this.num = num;
edges = Create(num, () => new List<Pair<int, Number>>());
}
public void AddEdge(int from, int to, Number weight) =>
edges[from].Add(new Pair<int, Number>(to, weight));
public Number[] Execute(int st = 0) {
var dist = Create(num, () => Number.MaxValue);
var pq = new PriorityQueue<Pair<int, long>>((a, b) => a.v2.CompareTo(b.v2));
pq.Enqueue(new Pair<int, Number>(st, 0));
dist[st] = 0;
while (pq.Any()) {
var p = pq.Dequeue();
if (p.v2 < dist[p.v1])
continue;
foreach (var e in edges[p.v1])
if (chmin(ref dist[e.v1], e.v2 + p.v2))
pq.Enqueue(new Pair<int, Number>(e.v1, dist[e.v1]));
}
return dist;
}
}
}
public class PriorityQueue<T> {
private List<T> item = new List<T>();
private Comparison<T> cmp;
public int Count {
get { return item.Count; }
}
public T Peek {
get { return item[0]; }
}
public PriorityQueue() { cmp = Comparer<T>.Default.Compare; }
public PriorityQueue(Comparison<T> comparison) { cmp = comparison; }
public PriorityQueue(IComparer<T> comparer) { cmp = comparer.Compare; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Parent(int i) => (i - 1) >> 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Left(int i) => (i << 1) + 1;
public T Enqueue(T val) {
int i = item.Count;
item.Add(val);
while (i > 0) {
int p = Parent(i);
if (cmp(item[p], val) <= 0)
break;
item[i] = item[p];
i = p;
}
item[i] = val;
return val;
}
public T Dequeue() {
var ret = item[0];
var p = 0;
var x = item[item.Count - 1];
while (Left(p) < item.Count - 1) {
var l = Left(p);
if (l < item.Count - 2 && cmp(item[l + 1], item[l]) < 0)
l++;
if (cmp(item[l], x) >= 0)
break;
item[p] = item[l];
p = l;
}
item[p] = x;
item.RemoveAt(item.Count - 1);
return ret;
}
public bool Any() => item.Count > 0;
}
#region Template
public class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) =>
Enumerable.Repeat(0, n).Select(_ => f()).ToArray();
public static void Fail() => Fail("No");
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new SolveSpace.Solver();
for (var i = 1; i > 0; --i)
p.Solve();
Console.Out.Flush();
}
}
public class Input {
public static string read => Console.ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => Convert.ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => Convert.ToInt64(read);
public static char[][] grid(int h) => Create(h, () => read.ToCharArray());
public static int[] ar1D(int n) => Create(n, () => num);
public static long[] arL1D(int n) => Create(n, () => numL);
public static string[] strs(int n) => Create(n, () => read);
public static int[][] ar2D(int n) => Create(n, () => ar);
public static long[][] arL2D(int n) => Create(n, () => arL);
public static List<T>[] edge<T>(int n) => Create(n, () => new List<T>());
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
static Input() {
sc = new Queue<string>();
dic = new Dictionary<Type, Func<string, object>>();
dic[typeof(int)] = s => int.Parse(s);
dic[typeof(long)] = s => long.Parse(s);
dic[typeof(char)] = s => char.Parse(s);
dic[typeof(double)] = s => double.Parse(s);
dic[typeof(uint)] = s => uint.Parse(s);
dic[typeof(ulong)] = s => ulong.Parse(s);
dic[typeof(string)] = s => s;
}
private static Dictionary<Type, Func<string, object>> dic;
private static Queue<string> sc;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Next<T>() {
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return (T)dic[typeof(T)](sc.Dequeue());
}
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
#endregion
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
namespace SolveSpace {
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;
using Number = System.Int64;
class Solver {
public void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kedge = new Dijkstra(num);
var yedge = new Dijkstra(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kedge.AddEdge(a, b, k);
kedge.AddEdge(b, a, k);
yedge.AddEdge(a, b, y);
yedge.AddEdge(b, a, y);
}
var kdist = kedge.Execute(t);
var ydist = yedge.Execute(s);
var inf = (long)1e15;
var res = new long[num];
var min = 0L;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
}
class Dijkstra {
private int num;
private List<Pair<int, Number>>[] edges;
public Dijkstra(int num) {
this.num = num;
edges = Create(num, () => new List<Pair<int, Number>>());
}
public void AddEdge(int from, int to, Number weight) =>
edges[from].Add(new Pair<int, Number>(to, weight));
public Number[] Execute(int st = 0) {
var dist = Create(num, () => Number.MaxValue);
var pq = new PriorityQueue<Pair<int, long>>((a, b) => a.v2.CompareTo(b.v2));
pq.Enqueue(new Pair<int, Number>(st, 0));
dist[st] = 0;
while (pq.Any()) {
var p = pq.Dequeue();
if (p.v2 < dist[p.v1])
continue;
foreach (var e in edges[p.v1])
if (chmin(ref dist[e.v1], e.v2 + p.v2))
pq.Enqueue(new Pair<int, Number>(e.v1, dist[e.v1]));
}
return dist;
}
}
}
public class PriorityQueue<T> {
private List<T> item = new List<T>();
private Comparison<T> cmp;
public int Count {
get { return item.Count; }
}
public T Peek {
get { return item[0]; }
}
public PriorityQueue() { cmp = Comparer<T>.Default.Compare; }
public PriorityQueue(Comparison<T> comparison) { cmp = comparison; }
public PriorityQueue(IComparer<T> comparer) { cmp = comparer.Compare; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Parent(int i) => (i - 1) >> 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Left(int i) => (i << 1) + 1;
public T Enqueue(T val) {
int i = item.Count;
item.Add(val);
while (i > 0) {
int p = Parent(i);
if (cmp(item[p], val) <= 0)
break;
item[i] = item[p];
i = p;
}
item[i] = val;
return val;
}
public T Dequeue() {
var ret = item[0];
var p = 0;
var x = item[item.Count - 1];
while (Left(p) < item.Count - 1) {
var l = Left(p);
if (l < item.Count - 2 && cmp(item[l + 1], item[l]) < 0)
l++;
if (cmp(item[l], x) >= 0)
break;
item[p] = item[l];
p = l;
}
item[p] = x;
item.RemoveAt(item.Count - 1);
return ret;
}
public bool Any() => item.Count > 0;
}
#region Template
public class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) =>
Enumerable.Repeat(0, n).Select(_ => f()).ToArray();
public static void Fail() => Fail("No");
public static void Fail<T>(T s) {
Console.WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new SolveSpace.Solver();
for (var i = 1; i > 0; --i)
p.Solve();
Console.Out.Flush();
}
}
public class Input {
public static string read => Console.ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => Convert.ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => Convert.ToInt64(read);
public static char[][] grid(int h) => Create(h, () => read.ToCharArray());
public static int[] ar1D(int n) => Create(n, () => num);
public static long[] arL1D(int n) => Create(n, () => numL);
public static string[] strs(int n) => Create(n, () => read);
public static int[][] ar2D(int n) => Create(n, () => ar);
public static long[][] arL2D(int n) => Create(n, () => arL);
public static List<T>[] edge<T>(int n) => Create(n, () => new List<T>());
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
static Input() {
sc = new Queue<string>();
dic = new Dictionary<Type, Func<string, object>>();
dic[typeof(int)] = s => int.Parse(s);
dic[typeof(long)] = s => long.Parse(s);
dic[typeof(char)] = s => char.Parse(s);
dic[typeof(double)] = s => double.Parse(s);
dic[typeof(uint)] = s => uint.Parse(s);
dic[typeof(ulong)] = s => ulong.Parse(s);
dic[typeof(string)] = s => s;
}
private static Dictionary<Type, Func<string, object>> dic;
private static Queue<string> sc;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Next<T>() {
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return (T)dic[typeof(T)](sc.Dequeue());
}
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1;
public T2 v2;
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3;
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
#endregion
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22]]
| 8
| 2,435
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;
using Graph;
// using DataStructure;
class Solver {
public void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kg = new Dijkstra(num);
var yg = new Dijkstra(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kg.AddEdge(a, b, k);
kg.AddEdge(b, a, k);
yg.AddEdge(a, b, y);
yg.AddEdge(b, a, y);
}
var kdist = kg.Calc(t);
var ydist = yg.Calc(s);
var inf = (long)1e15;
var res = new long[num];
var min = 0L;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
}
namespace Graph {
#region テンプレート
public class Graph<E>
where E : Edge {
public List<E>[] Edges { get; set; }
public int Count { get; }
public Graph(int count) {
Count = count;
Edges = Create(count, () => new List<E>());
}
}
public class Directed<E> : Graph<E>
where E : Edge {
public Directed(int count) : base(count) {}
}
public class Undirected<E> : Graph<E>
where E : Edge {
public Undirected(int count) : base(count) {}
}
public interface IWeight<T>
where T : IComparable<T> {
T Weight { get; set; }
}
public interface INNegWeight<T> : IWeight<T>
where T : IComparable<T> {}
public interface IEdge {
int From { get; }
int To { get; }
}
public class Edge {
public int From { get; set; }
public int To { get; set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public Edge(int from,
int to) {
From = from;
To = to;
}
}
#endregion
}
namespace Graph {
using Number = System.Int32;
public class Dijkstra {
private Graph<DijEdge> g;
public Dijkstra(int c) { g = new Graph<DijEdge>(c); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AddEdge(int from, int to,
Number weight) => g.Edges[from].Add(new DijEdge(from, to,
weight));
public Number[] Calc(int st = 0) {
var pq = new PriorityQueue<Pair<Number, int>>(false);
pq.Enqueue(new Pair<Number, int>(0, st));
var dist = Create(g.Count, () => Number.MaxValue);
dist[st] = 0;
var use = new bool[g.Count];
while (pq.Count != 0) {
var p = pq.Dequeue();
if (p.v1 > dist[p.v2] || use[p.v2])
continue;
use[p.v2] = true;
foreach (var e in g.Edges[p.v2])
if (!use[e.To] && chmin(ref dist[e.To], p.v1 + e.Weight))
pq.Enqueue(new Pair<Number, int>(dist[e.To], e.To));
}
return dist;
}
public class DijEdge : Edge, INNegWeight<Number> {
public Number Weight { get; set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public DijEdge(
int from, int to, Number weight)
: base(from, to) {
Weight = weight;
}
}
}
}
public class PriorityQueue<T>
where T : IComparable<T> {
public List<T> _item;
public int Count {
get { return _item.Count; }
}
public bool IsMaxHeap { get; set; }
public T Peek {
get { return _item[0]; }
}
public PriorityQueue(bool IsMaxHeap = true, IEnumerable<T> list = null) {
_item = new List<T>();
this.IsMaxHeap = IsMaxHeap;
if (list != null) {
_item.AddRange(list);
Build();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int
Compare(int i, int j) => (IsMaxHeap ? 1 : -1) * _item[i].CompareTo(_item[j]);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Swap(int i, int j) {
var t = _item[i];
_item[i] = _item[j];
_item[j] = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Parent(int i) => (i - 1) >> 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Left(int i) => (i << 1) + 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Enqueue(T val) {
int i = _item.Count;
_item.Add(val);
while (i > 0) {
int p = Parent(i);
if (Compare(i, p) > 0)
Swap(i, p);
i = p;
}
return val;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Heapify(int index) {
for (int i = index, j; (j = Left(i)) < _item.Count; i = j) {
if (j != _item.Count - 1 && Compare(j, j + 1) < 0)
j++;
if (Compare(i, j) < 0)
Swap(i, j);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Dequeue() {
T val = _item[0];
_item[0] = _item[_item.Count - 1];
_item.RemoveAt(_item.Count - 1);
Heapify(0);
return val;
}
private void Build() {
for (var i = (_item.Count >> 1) - 1; i >= 0; i--)
Heapify(i);
}
}
public class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) =>
Enumerable.Repeat(0, n).Select(_ => f()).ToArray();
public static void Fail() => Fail("No");
public static void Fail<T>(T s) {
WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new Solver();
for (var i = 1; i > 0; --i)
p.Solve();
Console.Out.Flush();
}
}
public class Input {
public static string read => ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => ToInt64(read);
public static char[][] grid(int h) => Create(h, () => read.ToCharArray());
public static int[] ar1D(int n) => Create(n, () => num);
public static long[] arL1D(int n) => Create(n, () => numL);
public static string[] strs(int n) => Create(n, () => read);
public static int[][] ar2D(int n) => Create(n, () => ar);
public static long[][] arL2D(int n) => Create(n, () => arL);
public static List<T>[] edge<T>(int n) => Create(n, () => new List<T>());
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
static Input() {
sc = new Queue<string>();
dic = new Dictionary<Type, Func<string, object>>();
dic[typeof(int)] = s => int.Parse(s);
dic[typeof(long)] = s => long.Parse(s);
dic[typeof(char)] = s => char.Parse(s);
dic[typeof(double)] = s => double.Parse(s);
dic[typeof(uint)] = s => uint.Parse(s);
dic[typeof(ulong)] = s => ulong.Parse(s);
dic[typeof(string)] = s => s;
}
private static Dictionary<Type, Func<string, object>> dic;
private static Queue<string> sc;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Next<T>() {
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return (T)dic[typeof(T)](sc.Dequeue());
}
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1 { get; set; }
public T2 v2 { get; set; }
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3 { get; set; }
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;
using Graph;
// using DataStructure;
class Solver {
public void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kg = new Dijkstra(num);
var yg = new Dijkstra(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kg.AddEdge(a, b, k);
kg.AddEdge(b, a, k);
yg.AddEdge(a, b, y);
yg.AddEdge(b, a, y);
}
var kdist = kg.Calc(t);
var ydist = yg.Calc(s);
var inf = (long)1e15;
var res = new long[num];
var min = 0L;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
}
namespace Graph {
#region テンプレート
public class Graph<E>
where E : Edge {
public List<E>[] Edges { get; set; }
public int Count { get; }
public Graph(int count) {
Count = count;
Edges = Create(count, () => new List<E>());
}
}
public class Directed<E> : Graph<E>
where E : Edge {
public Directed(int count) : base(count) {}
}
public class Undirected<E> : Graph<E>
where E : Edge {
public Undirected(int count) : base(count) {}
}
public interface IWeight<T>
where T : IComparable<T> {
T Weight { get; set; }
}
public interface INNegWeight<T> : IWeight<T>
where T : IComparable<T> {}
public interface IEdge {
int From { get; }
int To { get; }
}
public class Edge {
public int From { get; set; }
public int To { get; set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public Edge(int from,
int to) {
From = from;
To = to;
}
}
#endregion
}
namespace Graph {
using Number = System.Int64;
public class Dijkstra {
private Graph<DijEdge> g;
public Dijkstra(int c) { g = new Graph<DijEdge>(c); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AddEdge(int from, int to,
Number weight) => g.Edges[from].Add(new DijEdge(from, to,
weight));
public Number[] Calc(int st = 0) {
var pq = new PriorityQueue<Pair<Number, int>>(false);
pq.Enqueue(new Pair<Number, int>(0, st));
var dist = Create(g.Count, () => Number.MaxValue);
dist[st] = 0;
var use = new bool[g.Count];
while (pq.Count != 0) {
var p = pq.Dequeue();
if (p.v1 > dist[p.v2] || use[p.v2])
continue;
use[p.v2] = true;
foreach (var e in g.Edges[p.v2])
if (!use[e.To] && chmin(ref dist[e.To], p.v1 + e.Weight))
pq.Enqueue(new Pair<Number, int>(dist[e.To], e.To));
}
return dist;
}
public class DijEdge : Edge, INNegWeight<Number> {
public Number Weight { get; set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)] public DijEdge(
int from, int to, Number weight)
: base(from, to) {
Weight = weight;
}
}
}
}
public class PriorityQueue<T>
where T : IComparable<T> {
public List<T> _item;
public int Count {
get { return _item.Count; }
}
public bool IsMaxHeap { get; set; }
public T Peek {
get { return _item[0]; }
}
public PriorityQueue(bool IsMaxHeap = true, IEnumerable<T> list = null) {
_item = new List<T>();
this.IsMaxHeap = IsMaxHeap;
if (list != null) {
_item.AddRange(list);
Build();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int
Compare(int i, int j) => (IsMaxHeap ? 1 : -1) * _item[i].CompareTo(_item[j]);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Swap(int i, int j) {
var t = _item[i];
_item[i] = _item[j];
_item[j] = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Parent(int i) => (i - 1) >> 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private int Left(int i) => (i << 1) + 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Enqueue(T val) {
int i = _item.Count;
_item.Add(val);
while (i > 0) {
int p = Parent(i);
if (Compare(i, p) > 0)
Swap(i, p);
i = p;
}
return val;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Heapify(int index) {
for (int i = index, j; (j = Left(i)) < _item.Count; i = j) {
if (j != _item.Count - 1 && Compare(j, j + 1) < 0)
j++;
if (Compare(i, j) < 0)
Swap(i, j);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Dequeue() {
T val = _item[0];
_item[0] = _item[_item.Count - 1];
_item.RemoveAt(_item.Count - 1);
Heapify(0);
return val;
}
private void Build() {
for (var i = (_item.Count >> 1) - 1; i >= 0; i--)
Heapify(i);
}
}
public class Template {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T[] Create<T>(int n, Func<T> f) =>
Enumerable.Repeat(0, n).Select(_ => f()).ToArray();
public static void Fail() => Fail("No");
public static void Fail<T>(T s) {
WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new Solver();
for (var i = 1; i > 0; --i)
p.Solve();
Console.Out.Flush();
}
}
public class Input {
public static string read => ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => ToInt64(read);
public static char[][] grid(int h) => Create(h, () => read.ToCharArray());
public static int[] ar1D(int n) => Create(n, () => num);
public static long[] arL1D(int n) => Create(n, () => numL);
public static string[] strs(int n) => Create(n, () => read);
public static int[][] ar2D(int n) => Create(n, () => ar);
public static long[][] arL2D(int n) => Create(n, () => arL);
public static List<T>[] edge<T>(int n) => Create(n, () => new List<T>());
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
static Input() {
sc = new Queue<string>();
dic = new Dictionary<Type, Func<string, object>>();
dic[typeof(int)] = s => int.Parse(s);
dic[typeof(long)] = s => long.Parse(s);
dic[typeof(char)] = s => char.Parse(s);
dic[typeof(double)] = s => double.Parse(s);
dic[typeof(uint)] = s => uint.Parse(s);
dic[typeof(ulong)] = s => ulong.Parse(s);
dic[typeof(string)] = s => s;
}
private static Dictionary<Type, Func<string, object>> dic;
private static Queue<string> sc;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Next<T>() {
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return (T)dic[typeof(T)](sc.Dequeue());
}
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1 { get; set; }
public T2 v2 { get; set; }
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3 { get; set; }
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
|
[["-", 0, 209, 8, 201, 0, 231, 141, 232, 141, 22], ["+", 0, 209, 8, 201, 0, 231, 141, 232, 141, 22]]
| 8
| 2,851
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
using System.Text;
using Pi = csat.Pair<int, int>;
using PL = csat.Pair<long, int>;
namespace csat {
class Program {
public static bool chmin<T>(ref T t, T v)
where T : IComparable<T> {
if (t.CompareTo(v) == 1) {
t = v;
return true;
}
return false;
}
public static bool chmax<T>(ref T t, T v)
where T : IComparable<T> {
if (t.CompareTo(v) == -1) {
t = v;
return true;
}
return false;
}
public static void swap<T>(ref T t1, ref T t2) {
var tm = t1;
t1 = t2;
t2 = tm;
}
public static void Fail<T>(T s) {
WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new Program();
for (var i = 1; i > 0; i--)
p.Solve();
Console.Out.Flush();
}
void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kedge = Input.edge<Pair<long, int>>(num);
var yedge = Input.edge<Pair<long, int>>(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kedge[a].Add(new Pair<long, int>(k, b));
kedge[b].Add(new Pair<long, int>(k, a));
yedge[a].Add(new Pair<long, int>(y, b));
yedge[b].Add(new Pair<long, int>(y, a));
}
var kdist = Dijkstra(kedge, t);
var ydist = Dijkstra(yedge, s);
var inf = (long)1e15;
var res = new long[num];
var min = inf;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
public static long[] Dijkstra(IList<IEnumerable<Pair<long, int>>> edges,
int st) {
var dist = Enumerable.Repeat(long.MaxValue, edges.Count).ToArray();
var pq = new PriorityQueue<Pair<long, int>>(false);
pq.Enqueue(new Pair<long, int>(0, st));
dist[st] = 0;
while (pq.Count != 0) {
var p = pq.Dequeue();
if (dist[p.v2] < p.v1)
continue;
foreach (var e in edges[p.v2])
if (dist[e.v2] > e.v1 + dist[p.v2]) {
dist[e.v2] = e.v1 + dist[p.v2];
pq.Enqueue(new Pair<long, int>(dist[e.v2], e.v2));
}
}
return dist;
}
}
public class PriorityQueue<T>
where T : IComparable<T> {
public List<T> _item;
public int Count {
get { return _item.Count; }
}
public bool IsMaxHeap { get; set; }
public T Peek {
get { return _item[0]; }
}
public PriorityQueue(bool IsMaxHeap = true, IEnumerable<T> list = null) {
_item = new List<T>();
this.IsMaxHeap = IsMaxHeap;
if (list != null) {
_item.AddRange(list);
Build();
}
}
private int
Compare(int i, int j) => (IsMaxHeap ? 1 : -1) * _item[i].CompareTo(_item[j]);
private void Swap(int i, int j) {
var t = _item[i];
_item[i] = _item[j];
_item[j] = t;
}
private int Parent(int i) => (i - 1) >> 1;
private int Left(int i) => (i << 1) + 1;
public T Enqueue(T val) {
int i = _item.Count;
_item.Add(val);
while (i > 0) {
int p = Parent(i);
if (Compare(i, p) > 0)
Swap(i, p);
i = p;
}
return val;
}
private void Heapify(int index) {
for (int i = index, j; (j = Left(i)) < _item.Count; i = j) {
if (j != _item.Count - 1 && Compare(j, j + 1) < 0)
j++;
if (Compare(i, j) < 0)
Swap(i, j);
}
}
public T Dequeue() {
T val = _item[0];
_item[0] = _item[_item.Count - 1];
_item.RemoveAt(_item.Count - 1);
Heapify(0);
return val;
}
private void Build() {
for (var i = (_item.Count >> 1) - 1; i >= 0; i--)
Heapify(i);
}
}
public class Input {
public static string read => ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => ToInt64(read);
public static T[] create<T>(int n, Func<int, T> f) =>
Enumerable.Repeat(0, n).Select(f).ToArray();
public static char[][] grid(int h) => create(h, _ => read.ToCharArray());
public static int[] ar1D(int n) => create(n, _ => num);
public static long[] arL1D(int n) => create(n, _ => numL);
public static string[] strs(int n) => create(n, _ => read);
public static int[][] ar2D(int n) => create(n, _ => ar);
public static long[][] arL2D(int n) => create(n, _ => arL);
public static List<T>[] edge<T>(int n) => create(n, _ => new List<T>());
public static T GetValue<T>(string g) {
var t = typeof(T);
if (t == typeof(int))
return (T)(object) int.Parse(g);
if (t == typeof(long))
return (T)(object) long.Parse(g);
if (t == typeof(string))
return (T)(object)g;
if (t == typeof(char))
return (T)(object) char.Parse(g);
if (t == typeof(double))
return (T)(object) double.Parse(g);
if (t == typeof(bool))
return (T)(object) bool.Parse(g);
return default(T);
}
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
private static Queue<string> sc;
public static T Next<T>() {
sc = sc ?? new Queue<string>();
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return GetValue<T>(sc.Dequeue());
}
public static void Next<T>(ref T val) => val = Next<T>();
public const long Inf = (long)1e18;
public const double eps = 1e-6;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1 { get; set; }
public T2 v2 { get; set; }
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public override bool Equals(object obj) => this == (Pair<T1, T2>)obj;
public override int GetHashCode() => v1.GetHashCode() ^ v2.GetHashCode();
public static bool operator ==(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 0;
public static bool operator !=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 0;
public static bool operator>(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 1;
public static bool operator >=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != -1;
public static bool operator<(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == -1;
public static bool operator <=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 1;
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3 { get; set; }
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
using System.Text;
using Pi = csat.Pair<int, int>;
using PL = csat.Pair<long, int>;
namespace csat {
class Program {
public static bool chmin<T>(ref T t, T v)
where T : IComparable<T> {
if (t.CompareTo(v) == 1) {
t = v;
return true;
}
return false;
}
public static bool chmax<T>(ref T t, T v)
where T : IComparable<T> {
if (t.CompareTo(v) == -1) {
t = v;
return true;
}
return false;
}
public static void swap<T>(ref T t1, ref T t2) {
var tm = t1;
t1 = t2;
t2 = tm;
}
public static void Fail<T>(T s) {
WriteLine(s);
Console.Out.Close();
Environment.Exit(0);
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var p = new Program();
for (var i = 1; i > 0; i--)
p.Solve();
Console.Out.Flush();
}
void Solve() {
int num, m, s, t;
Input.Make(out num, out m, out s, out t);
s--;
t--;
var kedge = Input.edge<Pair<long, int>>(num);
var yedge = Input.edge<Pair<long, int>>(num);
for (var i = 0; i < m; i++) {
int a, b, y, k;
Input.Make(out a, out b, out y, out k);
a--;
b--;
kedge[a].Add(new Pair<long, int>(k, b));
kedge[b].Add(new Pair<long, int>(k, a));
yedge[a].Add(new Pair<long, int>(y, b));
yedge[b].Add(new Pair<long, int>(y, a));
}
var kdist = Dijkstra(kedge, t);
var ydist = Dijkstra(yedge, s);
var inf = (long)1e15;
var res = new long[num];
var min = 0L;
for (var i = num - 1; i >= 0; i--) {
chmax(ref min, inf - kdist[i] - ydist[i]);
res[i] = min;
}
WriteLine(string.Join("\n", res));
}
public static long[] Dijkstra(IList<IEnumerable<Pair<long, int>>> edges,
int st) {
var dist = Enumerable.Repeat(long.MaxValue, edges.Count).ToArray();
var pq = new PriorityQueue<Pair<long, int>>(false);
pq.Enqueue(new Pair<long, int>(0, st));
dist[st] = 0;
while (pq.Count != 0) {
var p = pq.Dequeue();
if (dist[p.v2] < p.v1)
continue;
foreach (var e in edges[p.v2])
if (dist[e.v2] > e.v1 + dist[p.v2]) {
dist[e.v2] = e.v1 + dist[p.v2];
pq.Enqueue(new Pair<long, int>(dist[e.v2], e.v2));
}
}
return dist;
}
}
public class PriorityQueue<T>
where T : IComparable<T> {
public List<T> _item;
public int Count {
get { return _item.Count; }
}
public bool IsMaxHeap { get; set; }
public T Peek {
get { return _item[0]; }
}
public PriorityQueue(bool IsMaxHeap = true, IEnumerable<T> list = null) {
_item = new List<T>();
this.IsMaxHeap = IsMaxHeap;
if (list != null) {
_item.AddRange(list);
Build();
}
}
private int
Compare(int i, int j) => (IsMaxHeap ? 1 : -1) * _item[i].CompareTo(_item[j]);
private void Swap(int i, int j) {
var t = _item[i];
_item[i] = _item[j];
_item[j] = t;
}
private int Parent(int i) => (i - 1) >> 1;
private int Left(int i) => (i << 1) + 1;
public T Enqueue(T val) {
int i = _item.Count;
_item.Add(val);
while (i > 0) {
int p = Parent(i);
if (Compare(i, p) > 0)
Swap(i, p);
i = p;
}
return val;
}
private void Heapify(int index) {
for (int i = index, j; (j = Left(i)) < _item.Count; i = j) {
if (j != _item.Count - 1 && Compare(j, j + 1) < 0)
j++;
if (Compare(i, j) < 0)
Swap(i, j);
}
}
public T Dequeue() {
T val = _item[0];
_item[0] = _item[_item.Count - 1];
_item.RemoveAt(_item.Count - 1);
Heapify(0);
return val;
}
private void Build() {
for (var i = (_item.Count >> 1) - 1; i >= 0; i--)
Heapify(i);
}
}
public class Input {
public static string read => ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => ToInt64(read);
public static T[] create<T>(int n, Func<int, T> f) =>
Enumerable.Repeat(0, n).Select(f).ToArray();
public static char[][] grid(int h) => create(h, _ => read.ToCharArray());
public static int[] ar1D(int n) => create(n, _ => num);
public static long[] arL1D(int n) => create(n, _ => numL);
public static string[] strs(int n) => create(n, _ => read);
public static int[][] ar2D(int n) => create(n, _ => ar);
public static long[][] arL2D(int n) => create(n, _ => arL);
public static List<T>[] edge<T>(int n) => create(n, _ => new List<T>());
public static T GetValue<T>(string g) {
var t = typeof(T);
if (t == typeof(int))
return (T)(object) int.Parse(g);
if (t == typeof(long))
return (T)(object) long.Parse(g);
if (t == typeof(string))
return (T)(object)g;
if (t == typeof(char))
return (T)(object) char.Parse(g);
if (t == typeof(double))
return (T)(object) double.Parse(g);
if (t == typeof(bool))
return (T)(object) bool.Parse(g);
return default(T);
}
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
private static Queue<string> sc;
public static T Next<T>() {
sc = sc ?? new Queue<string>();
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return GetValue<T>(sc.Dequeue());
}
public static void Next<T>(ref T val) => val = Next<T>();
public const long Inf = (long)1e18;
public const double eps = 1e-6;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1 { get; set; }
public T2 v2 { get; set; }
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public override bool Equals(object obj) => this == (Pair<T1, T2>)obj;
public override int GetHashCode() => v1.GetHashCode() ^ v2.GetHashCode();
public static bool operator ==(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 0;
public static bool operator !=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 0;
public static bool operator>(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 1;
public static bool operator >=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != -1;
public static bool operator<(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == -1;
public static bool operator <=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 1;
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3 { get; set; }
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 2,675
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
List<int>[] E = new List<int>[N];
for (int i = 0; i < N; i++) {
E[i] = new List<int>();
}
for (int i = 0; i < M; i++) {
E[U[i]].Add(i);
E[V[i]].Add(i);
}
long Inf = (long)1e18;
long[] mins = new long[N];
for (int i = 0; i < N; i++)
mins[i] = Inf;
bool[] used = new bool[N];
var SH = new SkewHeap<Pair>();
SH.Push(new Pair(S, 0));
mins[S] = 0;
while (SH.Count > 0) {
var p = SH.Top;
SH.Pop();
int now = p.Pos;
long cost = p.Cost;
if (used[now])
continue;
used[now] = true;
foreach (var ne in E[now]) {
int nxt = U[ne] == now ? V[ne] : U[ne];
if (mins[nxt] > cost + A[ne]) {
mins[nxt] = cost + A[ne];
SH.Push(new Pair(nxt, mins[nxt]));
}
}
}
long[] mint = new long[N];
for (int i = 0; i < N; i++)
mint[i] = Inf;
used = new bool[N];
SH = new SkewHeap<Pair>();
SH.Push(new Pair(T, 0));
mint[T] = 0;
while (SH.Count > 0) {
var p = SH.Top;
SH.Pop();
int now = p.Pos;
long cost = p.Cost;
if (used[now])
continue;
used[now] = true;
foreach (var ne in E[now]) {
int nxt = U[ne] == now ? V[ne] : U[ne];
if (mint[nxt] > cost + B[ne]) {
mint[nxt] = cost + B[ne];
SH.Push(new Pair(nxt, mins[nxt]));
}
}
}
long[] ans = new long[N];
for (int i = N - 1; i >= 0; i--) {
ans[i] = mins[i] + mint[i];
if (i + 1 < N) {
ans[i] = Math.Min(ans[i], ans[i + 1]);
}
}
long ini = 1000000000000000;
for (int i = 0; i < N; i++)
ans[i] = ini - ans[i];
Console.WriteLine(String.Join("\n", ans));
}
int N, M, S, T;
int[] U, V;
long[] A, B;
public Sol() {
/*
using(var r = new FastIn()){
N = r.ReadInt();
M = r.ReadInt();
S = r.ReadInt() - 1;
T = r.ReadInt() - 1;
U = new int[M];
V = new int[M];
A = new long[M];
B = new long[M];
for(int i=0;i<M;i++){
U[i] = r.ReadInt() - 1;
V[i] = r.ReadInt() - 1;
A[i] = r.ReadLong();
B[i] = r.ReadLong();
}
}
*/
var d = ria();
N = d[0];
M = d[1];
S = d[2] - 1;
T = d[3] - 1;
U = new int[M];
V = new int[M];
A = new long[M];
B = new long[M];
for (int i = 0; i < M; i++) {
var dd = ria();
U[i] = dd[0] - 1;
V[i] = dd[1] - 1;
A[i] = dd[2];
B[i] = dd[3];
}
}
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));
}
}
class Pair : IComparable<Pair> {
public int Pos;
public long Cost;
public Pair(int p, long c) {
Pos = p;
Cost = c;
}
public int CompareTo(Pair t) {
// return this.Cost > t.Cost ? -1 : this.Cost < t.Cost ? 1 : 0;
return this.Cost > t.Cost ? 1 : this.Cost < t.Cost ? -1 : 0;
}
}
class SkewHeap<T>
where T : IComparable<T> {
public int Count {
get { return cnt; }
private
set { cnt = value; }
}
public SkewHeap() {
root = null;
this.Count = 0;
}
public void Push(T v) {
NodeSH<T> p = new NodeSH<T>(v);
root = NodeSH<T>.Meld(root, p);
this.Count++;
}
public void Pop() {
if (root == null)
return;
root = NodeSH<T>.Meld(root.L, root.R);
this.Count--;
}
public T Top {
get { return root.Val; }
}
int cnt;
NodeSH<T> root;
class NodeSH<S>
where S : IComparable<S> {
public NodeSH<S> L, R;
public S Val;
public NodeSH(S v) {
Val = v;
L = null;
R = null;
}
public static NodeSH<S> Meld(NodeSH<S> a, NodeSH<S> b) {
if (a == null)
return b;
if (b == null)
return a;
if (a.Val.CompareTo(b.Val) > 0)
swap(ref a, ref b);
a.R = Meld(a.R, b);
swap(ref a.L, ref a.R);
return a;
}
static void swap<U>(ref U x, ref U y) {
U t = x;
x = y;
y = t;
}
}
}
class FastIn : IDisposable {
int Size;
byte[] Mem;
int ptr;
int rsize;
bool unfinished;
Stream stdin;
void Init(int n) {
Size = n;
Mem = new byte[Size];
rsize = (stdin = Console.OpenStandardInput()).Read(Mem, 0, Size);
ptr = 0;
unfinished = (rsize == Size);
}
void Next() {
if (unfinished == false)
return;
rsize = stdin.Read(Mem, 0, Size);
ptr = 0;
unfinished = (rsize == Size);
}
~FastIn() { stdin.Dispose(); }
void IDisposable.Dispose() { stdin.Dispose(); }
public void Dispose() { stdin.Dispose(); }
public FastIn() { Init(100000); }
public FastIn(int n) { Init(n); }
public int ReadInt() {
int ret = 0;
int sig = 1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
if (ret == 0 && Mem[ptr] == '-') {
sig *= -1;
ptr++;
continue;
}
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public uint ReadUint() {
uint ret = 0;
uint sig = 1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public long ReadLong() {
long ret = 0;
long sig = 1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
if (ret == 0 && Mem[ptr] == '-') {
sig *= -1;
ptr++;
continue;
}
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public double ReadDouble() {
double ret = 0;
double sig = 1;
bool dot = false;
double keta = 0.1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
if (ret == 0 && Mem[ptr] == '-') {
sig *= -1;
ptr++;
if (ptr == Size)
Next();
continue;
}
if (Mem[ptr] == '.') {
dot = true;
ptr++;
if (ptr == Size)
Next();
continue;
}
if (!dot) {
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
} else {
ret = ret + (Mem[ptr++] - '0') * keta;
keta /= 10.0;
if (ptr == Size)
Next();
}
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public String ReadStr() {
// 2byte文字はNG
StringBuilder sb = new StringBuilder();
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
sb.Append((char)Mem[ptr++]);
if (ptr == Size && unfinished)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size && unfinished)
Next();
}
return sb.ToString();
}
public String ReadLine() {
//極力使わない(split/parseするくらいなら上をつかう)
StringBuilder sb = new StringBuilder();
while (ptr < rsize && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
sb.Append((char)Mem[ptr++]);
if (ptr == Size && unfinished)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size && unfinished)
Next();
}
return sb.ToString();
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class TEST {
static void Main() {
Sol mySol = new Sol();
mySol.Solve();
}
}
class Sol {
public void Solve() {
List<int>[] E = new List<int>[N];
for (int i = 0; i < N; i++) {
E[i] = new List<int>();
}
for (int i = 0; i < M; i++) {
E[U[i]].Add(i);
E[V[i]].Add(i);
}
long Inf = (long)1e18;
long[] mins = new long[N];
for (int i = 0; i < N; i++)
mins[i] = Inf;
bool[] used = new bool[N];
var SH = new SkewHeap<Pair>();
SH.Push(new Pair(S, 0));
mins[S] = 0;
while (SH.Count > 0) {
var p = SH.Top;
SH.Pop();
int now = p.Pos;
long cost = p.Cost;
if (used[now])
continue;
used[now] = true;
foreach (var ne in E[now]) {
int nxt = U[ne] == now ? V[ne] : U[ne];
if (mins[nxt] > cost + A[ne]) {
mins[nxt] = cost + A[ne];
SH.Push(new Pair(nxt, mins[nxt]));
}
}
}
long[] mint = new long[N];
for (int i = 0; i < N; i++)
mint[i] = Inf;
used = new bool[N];
SH = new SkewHeap<Pair>();
SH.Push(new Pair(T, 0));
mint[T] = 0;
while (SH.Count > 0) {
var p = SH.Top;
SH.Pop();
int now = p.Pos;
long cost = p.Cost;
if (used[now])
continue;
used[now] = true;
foreach (var ne in E[now]) {
int nxt = U[ne] == now ? V[ne] : U[ne];
if (mint[nxt] > cost + B[ne]) {
mint[nxt] = cost + B[ne];
SH.Push(new Pair(nxt, mint[nxt]));
}
}
}
long[] ans = new long[N];
for (int i = N - 1; i >= 0; i--) {
ans[i] = mins[i] + mint[i];
if (i + 1 < N) {
ans[i] = Math.Min(ans[i], ans[i + 1]);
}
}
long ini = 1000000000000000;
for (int i = 0; i < N; i++)
ans[i] = ini - ans[i];
Console.WriteLine(String.Join("\n", ans));
}
int N, M, S, T;
int[] U, V;
long[] A, B;
public Sol() {
/*
using(var r = new FastIn()){
N = r.ReadInt();
M = r.ReadInt();
S = r.ReadInt() - 1;
T = r.ReadInt() - 1;
U = new int[M];
V = new int[M];
A = new long[M];
B = new long[M];
for(int i=0;i<M;i++){
U[i] = r.ReadInt() - 1;
V[i] = r.ReadInt() - 1;
A[i] = r.ReadLong();
B[i] = r.ReadLong();
}
}
*/
var d = ria();
N = d[0];
M = d[1];
S = d[2] - 1;
T = d[3] - 1;
U = new int[M];
V = new int[M];
A = new long[M];
B = new long[M];
for (int i = 0; i < M; i++) {
var dd = ria();
U[i] = dd[0] - 1;
V[i] = dd[1] - 1;
A[i] = dd[2];
B[i] = dd[3];
}
}
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));
}
}
class Pair : IComparable<Pair> {
public int Pos;
public long Cost;
public Pair(int p, long c) {
Pos = p;
Cost = c;
}
public int CompareTo(Pair t) {
// return this.Cost > t.Cost ? -1 : this.Cost < t.Cost ? 1 : 0;
return this.Cost > t.Cost ? 1 : this.Cost < t.Cost ? -1 : 0;
}
}
class SkewHeap<T>
where T : IComparable<T> {
public int Count {
get { return cnt; }
private
set { cnt = value; }
}
public SkewHeap() {
root = null;
this.Count = 0;
}
public void Push(T v) {
NodeSH<T> p = new NodeSH<T>(v);
root = NodeSH<T>.Meld(root, p);
this.Count++;
}
public void Pop() {
if (root == null)
return;
root = NodeSH<T>.Meld(root.L, root.R);
this.Count--;
}
public T Top {
get { return root.Val; }
}
int cnt;
NodeSH<T> root;
class NodeSH<S>
where S : IComparable<S> {
public NodeSH<S> L, R;
public S Val;
public NodeSH(S v) {
Val = v;
L = null;
R = null;
}
public static NodeSH<S> Meld(NodeSH<S> a, NodeSH<S> b) {
if (a == null)
return b;
if (b == null)
return a;
if (a.Val.CompareTo(b.Val) > 0)
swap(ref a, ref b);
a.R = Meld(a.R, b);
swap(ref a.L, ref a.R);
return a;
}
static void swap<U>(ref U x, ref U y) {
U t = x;
x = y;
y = t;
}
}
}
class FastIn : IDisposable {
int Size;
byte[] Mem;
int ptr;
int rsize;
bool unfinished;
Stream stdin;
void Init(int n) {
Size = n;
Mem = new byte[Size];
rsize = (stdin = Console.OpenStandardInput()).Read(Mem, 0, Size);
ptr = 0;
unfinished = (rsize == Size);
}
void Next() {
if (unfinished == false)
return;
rsize = stdin.Read(Mem, 0, Size);
ptr = 0;
unfinished = (rsize == Size);
}
~FastIn() { stdin.Dispose(); }
void IDisposable.Dispose() { stdin.Dispose(); }
public void Dispose() { stdin.Dispose(); }
public FastIn() { Init(100000); }
public FastIn(int n) { Init(n); }
public int ReadInt() {
int ret = 0;
int sig = 1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
if (ret == 0 && Mem[ptr] == '-') {
sig *= -1;
ptr++;
continue;
}
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public uint ReadUint() {
uint ret = 0;
uint sig = 1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public long ReadLong() {
long ret = 0;
long sig = 1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
if (ret == 0 && Mem[ptr] == '-') {
sig *= -1;
ptr++;
continue;
}
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public double ReadDouble() {
double ret = 0;
double sig = 1;
bool dot = false;
double keta = 0.1;
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
if (ret == 0 && Mem[ptr] == '-') {
sig *= -1;
ptr++;
if (ptr == Size)
Next();
continue;
}
if (Mem[ptr] == '.') {
dot = true;
ptr++;
if (ptr == Size)
Next();
continue;
}
if (!dot) {
ret = ret * 10 + Mem[ptr++] - '0';
if (ptr == Size)
Next();
} else {
ret = ret + (Mem[ptr++] - '0') * keta;
keta /= 10.0;
if (ptr == Size)
Next();
}
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size)
Next();
}
return ret * sig;
}
public String ReadStr() {
// 2byte文字はNG
StringBuilder sb = new StringBuilder();
while (ptr < rsize && Mem[ptr] != ' ' && Mem[ptr] != '\n' &&
Mem[ptr] != '\r') {
sb.Append((char)Mem[ptr++]);
if (ptr == Size && unfinished)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size && unfinished)
Next();
}
return sb.ToString();
}
public String ReadLine() {
//極力使わない(split/parseするくらいなら上をつかう)
StringBuilder sb = new StringBuilder();
while (ptr < rsize && Mem[ptr] != '\n' && Mem[ptr] != '\r') {
sb.Append((char)Mem[ptr++]);
if (ptr == Size && unfinished)
Next();
}
while (ptr < rsize &&
(Mem[ptr] == ' ' || Mem[ptr] == '\n' || Mem[ptr] == '\r')) {
ptr++;
if (ptr == Size && unfinished)
Next();
}
return sb.ToString();
}
}
|
[["-", 0, 230, 3, 4, 0, 28, 0, 204, 205, 22], ["+", 0, 230, 3, 4, 0, 28, 0, 204, 205, 22]]
| 8
| 2,619
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
using System.Text;
class Program {
private static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
private static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
private static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
static void Main(string[] args) {
var pr = new Program();
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
pr.Solve();
Console.Out.Flush();
}
long a = -1;
int[] co;
long[] dist;
List<Pair<long, int>>[] edge;
bool f;
void Solve() {
int num, m;
Input.Make(out num, out m);
edge = Input.edge<Pair<long, int>>(num);
for (var i = 0; i < m; i++) {
int u, v, s;
Input.Make(out u, out v, out s);
u--;
v--;
edge[u].Add(new Pair<long, int>(s, v));
edge[v].Add(new Pair<long, int>(s, u));
}
co = new int[num];
dist = Enumerable.Repeat(-1L, num).ToArray();
dist[0] = 0;
dfs(0, 1);
if (f) {
WriteLine(0);
return;
}
if (a != -1) {
WriteLine(
Enumerable.Range(0, num).All(v => (co[v] == 1 && dist[v] + a > 0) ||
(co[v] == 2 && dist[v] - a > 0))
? 1
: 0);
return;
}
var max = long.MaxValue;
var min = 1L;
for (var i = 0; i < num; i++)
if (co[i] == 1)
chmax(ref min, -dist[i]);
else
chmin(ref max, dist[i]);
WriteLine(Max(0, max - min));
}
public void dfs(int index, int c) {
co[index] = c;
foreach (var e in edge[index]) {
if (f)
goto F;
if (co[e.v2] != 0) {
if (co[e.v2] != co[index]) {
f = dist[e.v2] + dist[index] != e.v1;
continue;
}
var d = (co[index] == 1 ? 1 : -1) * (e.v1 - dist[index] - dist[e.v2]);
if (a == -1)
a = d / 2;
if (d % 2 != 0 || a != d / 2 || a <= 0)
f = true;
continue;
}
dist[e.v2] = e.v1 - dist[index];
dfs(e.v2, c ^ 3);
}
F:;
}
}
public class Input {
public static string read => ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => ToInt64(read);
public static T[] create<T>(int n, Func<int, T> f) =>
Enumerable.Repeat(0, n).Select(f).ToArray();
public static char[][] grid(int h) => create(h, _ => read.ToCharArray());
public static int[] ar1D(int n) => create(n, _ => num);
public static long[] arL1D(int n) => create(n, _ => numL);
public static string[] strs(int n) => create(n, _ => read);
public static int[][] ar2D(int n) => create(n, _ => ar);
public static long[][] arL2D(int n) => create(n, _ => arL);
public static List<T>[] edge<T>(int n) => create(n, _ => new List<T>());
public static T GetValue<T>(string g) {
var t = typeof(T);
if (t == typeof(int))
return (T)(object) int.Parse(g);
if (t == typeof(long))
return (T)(object) long.Parse(g);
if (t == typeof(string))
return (T)(object)g;
if (t == typeof(char))
return (T)(object) char.Parse(g);
if (t == typeof(double))
return (T)(object) double.Parse(g);
if (t == typeof(bool))
return (T)(object) bool.Parse(g);
return default(T);
}
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
private static Queue<string> sc;
public static T Next<T>() {
sc = sc ?? new Queue<string>();
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return GetValue<T>(sc.Dequeue());
}
public static void Next<T>(ref T val) => val = Next<T>();
public const long Inf = (long)1e18;
public const double eps = 1e-6;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1 { get; set; }
public T2 v2 { get; set; }
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public override bool Equals(object obj) => this == (Pair<T1, T2>)obj;
public override int GetHashCode() => v1.GetHashCode() ^ v2.GetHashCode();
public static bool operator ==(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 0;
public static bool operator !=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 0;
public static bool operator>(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 1;
public static bool operator >=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != -1;
public static bool operator<(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == -1;
public static bool operator <=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 1;
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3 { get; set; }
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
// using static System.Globalization.CultureInfo;
using System.Text;
class Program {
private static bool chmin<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == 1) {
num = val;
return true;
}
return false;
}
private static bool chmax<T>(ref T num, T val)
where T : IComparable<T> {
if (num.CompareTo(val) == -1) {
num = val;
return true;
}
return false;
}
private static void swap<T>(ref T v1, ref T v2) {
var t = v2;
v2 = v1;
v1 = t;
}
static void Main(string[] args) {
var pr = new Program();
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
pr.Solve();
Console.Out.Flush();
}
long a = -1;
int[] co;
long[] dist;
List<Pair<long, int>>[] edge;
bool f;
void Solve() {
int num, m;
Input.Make(out num, out m);
edge = Input.edge<Pair<long, int>>(num);
for (var i = 0; i < m; i++) {
int u, v, s;
Input.Make(out u, out v, out s);
u--;
v--;
edge[u].Add(new Pair<long, int>(s, v));
edge[v].Add(new Pair<long, int>(s, u));
}
co = new int[num];
dist = Enumerable.Repeat(-1L, num).ToArray();
dist[0] = 0;
dfs(0, 1);
if (f) {
WriteLine(0);
return;
}
if (a != -1) {
WriteLine(
Enumerable.Range(0, num).All(v => (co[v] == 1 && dist[v] + a > 0) ||
(co[v] == 2 && dist[v] - a > 0))
? 1
: 0);
return;
}
var max = long.MaxValue;
var min = 1L;
for (var i = 0; i < num; i++)
if (co[i] == 1)
chmax(ref min, -dist[i] + 1);
else
chmin(ref max, dist[i] - 1);
WriteLine(Max(0, max - min + 1));
}
public void dfs(int index, int c) {
co[index] = c;
foreach (var e in edge[index]) {
if (f)
goto F;
if (co[e.v2] != 0) {
if (co[e.v2] != co[index]) {
f = dist[e.v2] + dist[index] != e.v1;
continue;
}
var d = (co[index] == 1 ? 1 : -1) * (e.v1 - dist[index] - dist[e.v2]);
if (a == -1)
a = d / 2;
if (d % 2 != 0 || a != d / 2 || a <= 0)
f = true;
continue;
}
dist[e.v2] = e.v1 - dist[index];
dfs(e.v2, c ^ 3);
}
F:;
}
}
public class Input {
public static string read => ReadLine().Trim();
public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
public static int num => ToInt32(read);
public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
public static long numL => ToInt64(read);
public static T[] create<T>(int n, Func<int, T> f) =>
Enumerable.Repeat(0, n).Select(f).ToArray();
public static char[][] grid(int h) => create(h, _ => read.ToCharArray());
public static int[] ar1D(int n) => create(n, _ => num);
public static long[] arL1D(int n) => create(n, _ => numL);
public static string[] strs(int n) => create(n, _ => read);
public static int[][] ar2D(int n) => create(n, _ => ar);
public static long[][] arL2D(int n) => create(n, _ => arL);
public static List<T>[] edge<T>(int n) => create(n, _ => new List<T>());
public static T GetValue<T>(string g) {
var t = typeof(T);
if (t == typeof(int))
return (T)(object) int.Parse(g);
if (t == typeof(long))
return (T)(object) long.Parse(g);
if (t == typeof(string))
return (T)(object)g;
if (t == typeof(char))
return (T)(object) char.Parse(g);
if (t == typeof(double))
return (T)(object) double.Parse(g);
if (t == typeof(bool))
return (T)(object) bool.Parse(g);
return default(T);
}
public static void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public static void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public static void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public static void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public static void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2,
out T3 v3, out T4 v4,
out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
private static Queue<string> sc;
public static T Next<T>() {
sc = sc ?? new Queue<string>();
if (sc.Count == 0)
foreach (var item in read.Split(' '))
sc.Enqueue(item);
return GetValue<T>(sc.Dequeue());
}
public static void Next<T>(ref T val) => val = Next<T>();
public const long Inf = (long)1e18;
public const double eps = 1e-6;
public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
public const int MOD = 1000000007;
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>> {
public T1 v1 { get; set; }
public T2 v2 { get; set; }
public Pair() {
v1 = Input.Next<T1>();
v2 = Input.Next<T2>();
}
public Pair(T1 v1, T2 v2) {
this.v1 = v1;
this.v2 = v2;
}
public int CompareTo(Pair<T1, T2> p) {
var c = Comparer<T1>.Default.Compare(v1, p.v1);
if (c == 0)
c = Comparer<T2>.Default.Compare(v2, p.v2);
return c;
}
public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
public override bool Equals(object obj) => this == (Pair<T1, T2>)obj;
public override int GetHashCode() => v1.GetHashCode() ^ v2.GetHashCode();
public static bool operator ==(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 0;
public static bool operator !=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 0;
public static bool operator>(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == 1;
public static bool operator >=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != -1;
public static bool operator<(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) == -1;
public static bool operator <=(Pair<T1, T2> p1,
Pair<T1, T2> p2) => p1.CompareTo(p2) != 1;
}
public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>> {
public T3 v3 { get; set; }
public Pair() : base() { v3 = Input.Next<T3>(); }
public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2) { this.v3 = v3; }
public int CompareTo(Pair<T1, T2, T3> p) {
var c = base.CompareTo(p);
if (c == 0)
c = Comparer<T3>.Default.Compare(v3, p.v3);
return c;
}
public override string ToString() => $"{base.ToString()} {v3.ToString()}";
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 33]]
| 8
| 2,191
| 6
|
using System;
class Program {
static void Main(string[] args) {
var num = Convert.ToInt32(Console.ReadLine());
if (num % 2 == 0)
Console.WriteLine(num / 2);
else
Console.WriteLine(num * 2);
}
}
|
using System;
class Program {
static void Main(string[] args) {
var num = Convert.ToInt32(Console.ReadLine());
if (num % 2 == 0)
Console.WriteLine(num);
else
Console.WriteLine(num * 2);
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 85], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 59
| 2
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
if (N % 2 == 0)
Console.WriteLine("N");
else
Console.WriteLine(2 * N);
}
}
}
|
using System;
namespace A {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
if (N % 2 == 0)
Console.WriteLine(N);
else
Console.WriteLine(2 * N);
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62]]
| 8
| 63
| 2
|
using System;
class Program {
static void Main() {
int s = int.Parse(Console.ReadLine());
int a = 0;
if (s % 2 == 0) {
a = 2;
} else {
a = s * 2;
}
Console.WriteLine(a);
}
}
|
using System;
class Program {
static void Main() {
int s = int.Parse(Console.ReadLine());
int a = 0;
if (s % 2 == 0) {
a = s;
} else {
a = s * 2;
}
Console.WriteLine(a);
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 63
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionD {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long max = 0;
long min = 10000;
for (int i = 0; i < n; i++) {
if (inputLongArray[i] < min) {
min = inputLongArray[i];
} else if (inputLongArray[i] > max) {
max = inputLongArray[i];
}
}
Console.WriteLine(max - min);
Console.Out.Flush();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoder.Abc {
class QuestionD {
public static void Main(string[] args) {
var sw = new System.IO.StreamWriter(
Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
// 整数の入力
long n = long.Parse(Console.ReadLine());
// 整数配列の入力
var inputLongArray =
Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
long max = 0;
long min = 1000000000;
for (int i = 0; i < n; i++) {
if (inputLongArray[i] < min) {
min = inputLongArray[i];
}
if (inputLongArray[i] > max) {
max = inputLongArray[i];
}
}
Console.WriteLine(max - min);
Console.Out.Flush();
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95]]
| 8
| 206
| 3
|
using System;
namespace B___Maximum_Difference {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var input = Console.ReadLine().Split(' ');
var a = new int[n];
var b = 0;
for (var i = 0; i < n; i++) {
a[i] = int.Parse(input[i]);
}
for (var i = 0; i < n - i; i++) {
for (var j = 1; j < n; j++) {
if (b < Math.Abs(a[i] - a[j])) {
b = Math.Abs(a[i] - a[j]);
}
}
}
Console.WriteLine(b);
}
}
}
|
using System;
namespace B___Maximum_Difference {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
var input = Console.ReadLine().Split(' ');
var a = new int[n];
var b = 0;
for (var i = 0; i < n; i++) {
a[i] = int.Parse(input[i]);
}
for (var i = 0; i < n - 1; i++) {
for (var j = 1; j < n; j++) {
if (b < Math.Abs(a[i] - a[j])) {
b = Math.Abs(a[i] - a[j]);
}
}
}
Console.WriteLine(b);
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 176
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z {
static void Main() => new K();
}
class K {
int F => int.Parse(Str);
long FL => long.Parse(Str);
int[] G => Strs.Select(int.Parse).ToArray();
uint[] GU => Strs.Select(uint.Parse).ToArray();
decimal[] GD => Strs.Select(decimal.Parse).ToArray();
long[] GL => Strs.Select(long.Parse).ToArray();
string Str => ReadLine();
string[] Strs => Str.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries);
static T[] ConstantArray<T>(int n, T val) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = val;
return a;
}
static T[] MakeArray<T>(int n, Func<int, T> f) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = f(i);
return a;
}
static ulong One(int k) => 1ul << k;
static ulong All(int k) => One(k) - 1;
static bool Has(ulong s, int k) => (s & One(k)) != 0;
const int MOD = 1000000007;
public K() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
}
void Solve() {
var I = G;
WriteLine(I.Max() - I.Min());
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z {
static void Main() => new K();
}
class K {
int F => int.Parse(Str);
long FL => long.Parse(Str);
int[] G => Strs.Select(int.Parse).ToArray();
uint[] GU => Strs.Select(uint.Parse).ToArray();
decimal[] GD => Strs.Select(decimal.Parse).ToArray();
long[] GL => Strs.Select(long.Parse).ToArray();
string Str => ReadLine();
string[] Strs => Str.Split(new char[] { ' ', '\t' },
StringSplitOptions.RemoveEmptyEntries);
static T[] ConstantArray<T>(int n, T val) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = val;
return a;
}
static T[] MakeArray<T>(int n, Func<int, T> f) {
var a = new T[n];
for (var i = 0; i < n; i++)
a[i] = f(i);
return a;
}
static ulong One(int k) => 1ul << k;
static ulong All(int k) => One(k) - 1;
static bool Has(ulong s, int k) => (s & One(k)) != 0;
const int MOD = 1000000007;
public K() {
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
Solve();
Out.Flush();
}
void Solve() {
var N = F;
var I = G;
WriteLine(I.Max() - I.Min());
}
}
|
[["+", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 32], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 22], ["+", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["+", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217]]
| 8
| 421
| 5
|
using System;
using System.Linq;
public class B {
static void Main(string[] args) {
var inputs = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
Console.WriteLine(inputs.Max() - inputs.Min());
}
}
|
using System;
using System.Linq;
public class B {
static void Main(string[] args) {
Console.ReadLine();
var inputs = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
Console.WriteLine(inputs.Max() - inputs.Min());
}
}
|
[["+", 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
| 66
| 6
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] AElem = Console.ReadLine().Split(' ');
List<int> A = new List<int>();
for (int i = 0; i < N + 1; i++) {
A.Add(int.Parse(AElem[i]));
}
A.Sort();
int min = A[0];
int max = A[N - 1];
int ans = max - min;
Console.WriteLine(ans);
return;
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string[] AElem = Console.ReadLine().Split(' ');
List<int> A = new List<int>();
for (int i = 0; i < N; i++) {
A.Add(int.Parse(AElem[i]));
}
A.Sort();
int min = A[0];
int max = A[N - 1];
int ans = max - min;
Console.WriteLine(ans);
return;
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 144
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Test {
class MainClass {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var s = Console.ReadLine().Split(' ');
var a = new int[100];
int maxval = -1;
int minval = 101;
for (int i = 0; i < n; i++) {
a[i] = int.Parse(s[i]);
maxval = Math.Max(maxval, a[i]);
minval = Math.Min(minval, a[i]);
}
Console.WriteLine(maxval - minval);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace Test {
class MainClass {
static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
var s = Console.ReadLine().Split(' ');
var a = new int[100];
int maxval = -1;
int minval = 1000000001;
for (int i = 0; i < n; i++) {
a[i] = int.Parse(s[i]);
maxval = Math.Max(maxval, a[i]);
minval = Math.Min(minval, a[i]);
}
Console.WriteLine(maxval - minval);
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 152
| 2
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace atPra {
class Class1 {
static void Main() {
var N = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(null);
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = int.Parse(str[i]);
}
//最大値を求める
int max = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= max)
max = A[i];
}
//最小値を求める
int min = 99999999;
for (int i = 0; i < N; i++) {
if (A[i] <= min)
min = A[i];
}
Console.WriteLine(max - min);
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace atPra {
class Class1 {
static void Main() {
var N = int.Parse(Console.ReadLine());
string[] str = Console.ReadLine().Split(null);
int[] A = new int[N];
for (int i = 0; i < N; i++) {
A[i] = int.Parse(str[i]);
}
//最大値を求める
int max = 0;
for (int i = 0; i < N; i++) {
if (A[i] >= max)
max = A[i];
}
//最小値を求める
int min = 1000000000;
for (int i = 0; i < N; i++) {
if (A[i] <= min)
min = A[i];
}
Console.WriteLine(max - min);
}
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 209
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = int.Parse(Console.ReadLine());
var array = Console.ReadLine().Split(' ');
var list = new List<long>();
for (var i = 1; i < array.Length + 1; i++) {
var n = long.Parse(array[i - 1]);
list.Add(n - i);
}
list.Sort();
long mid = 0;
if (input % 2 == 0) {
mid = list[input / 2 - 1];
} else {
mid = list[input + 1 / 2 - 1];
}
var ansList = new List<long>();
foreach (var n in list) {
ansList.Add(Math.Abs(n - mid));
}
Console.WriteLine(ansList.Sum());
Console.ReadLine();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var input = int.Parse(Console.ReadLine());
var array = Console.ReadLine().Split(' ');
var list = new List<long>();
for (var i = 1; i < array.Length + 1; i++) {
var n = long.Parse(array[i - 1]);
list.Add(n - i);
}
list.Sort();
long mid = 0;
if (input % 2 == 0) {
mid = list[input / 2 - 1];
} else {
mid = list[(input + 1) / 2 - 1];
}
var ansList = new List<long>();
foreach (var n in list) {
ansList.Add(Math.Abs(n - mid));
}
Console.WriteLine(ansList.Sum());
Console.ReadLine();
}
}
|
[["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 214
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp90 {
class Program {
static long N;
static long[] A;
static void Main(string[] args) {
N = long.Parse(Console.ReadLine());
A = Console.ReadLine().Split().Select(long.Parse).ToArray();
var A_new = new long[N];
for (int i = 0; i < N; i++) {
A_new[i] = A[i] + i + 1;
}
var minMaxList = new List<long>();
for (int i = 0; i < N; i++) {
minMaxList.Add(A[i] - (i + 1));
}
long min = minMaxList.Min();
long max = minMaxList.Max();
Console.WriteLine(Calculate(minMaxList[(int)N / 2]));
//答え(正確にはb)はminとmaxの間にある!!→二分探索!
// Console.WriteLine("min : " + min);
// Console.WriteLine("max : " + max);
// long ans = Calculate(max);
// for (long i = min; i <= max; i++) {
// ans = Math.Min(ans, Calculate(i));
//}
// Console.WriteLine(ans);
}
// static bool CheckRightOrLeft(int min_, int max_) {
// int middle = (min_ + max_) / 2;
//}
//悲しさを計算する
static long Calculate(long b_) {
long value = 0;
for (int i = 0; i < N; i++) {
value += Math.Abs(A[i] - (b_ + i + 1));
}
return value;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp90 {
class Program {
static long N;
static long[] A;
static void Main(string[] args) {
N = long.Parse(Console.ReadLine());
A = Console.ReadLine().Split().Select(long.Parse).ToArray();
var A_new = new long[N];
for (int i = 0; i < N; i++) {
A_new[i] = A[i] + i + 1;
}
var minMaxList = new List<long>();
for (int i = 0; i < N; i++) {
minMaxList.Add(A[i] - (i + 1));
}
long min = minMaxList.Min();
long max = minMaxList.Max();
minMaxList.Sort();
Console.WriteLine(Calculate(minMaxList[(int)N / 2]));
//答え(正確にはb)はminとmaxの間にある!!→二分探索!
// Console.WriteLine("min : " + min);
// Console.WriteLine("max : " + max);
// long ans = Calculate(max);
// for (long i = min; i <= max; i++) {
// ans = Math.Min(ans, Calculate(i));
//}
// Console.WriteLine(ans);
}
// static bool CheckRightOrLeft(int min_, int max_) {
// int middle = (min_ + max_) / 2;
//}
//悲しさを計算する
static long Calculate(long b_) {
long value = 0;
for (int i = 0; i < N; i++) {
value += Math.Abs(A[i] - (b_ + i + 1));
}
return value;
}
}
}
|
[["+", 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
| 275
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
// var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
// var watch = new Stopwatch();
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
long suma = 0;
long sumb = 0;
for (var i = 0; i < N; i++) {
a[i] -= i + 1;
}
if (N == 1) {
Console.WriteLine(a[0]);
Console.Out.Flush();
return;
}
Array.Sort(a);
int m = a[N / 2];
int mm = a[N / 2 + 1];
for (var i = 0; i < N; i++) {
suma += Math.Abs(a[i] - m);
sumb += Math.Abs(a[i] - mm);
}
Console.WriteLine(Math.Min(suma, sumb));
// watch.Start();
Console.Out.Flush();
/*watch.Stop();
Console.WriteLine($"time:{watch.ElapsedMilliseconds} ms"); //Debug Only.
Console.Out.Flush();*/
}
}
public class Calculation {}
public class Graph {}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
// var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
// var watch = new Stopwatch();
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
long suma = 0;
long sumb = 0;
for (var i = 0; i < N; i++) {
a[i] -= i + 1;
}
if (N == 1) {
Console.WriteLine(0);
Console.Out.Flush();
return;
}
Array.Sort(a);
int m = a[N / 2];
int mm = a[N / 2 + 1];
for (var i = 0; i < N; i++) {
suma += Math.Abs(a[i] - m);
sumb += Math.Abs(a[i] - mm);
}
Console.WriteLine(Math.Min(suma, sumb));
// watch.Start();
Console.Out.Flush();
/*watch.Stop();
Console.WriteLine($"time:{watch.ElapsedMilliseconds} ms"); //Debug Only.
Console.Out.Flush();*/
}
}
public class Calculation {}
public class Graph {}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 204, 205, 22], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 70], ["-", 3, 4, 0, 28, 0, 204, 206, 207, 0, 73]]
| 8
| 297
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass {
static void Main(string[] args) { Answer(); }
public static void Answer() {
var line = Console.ReadLine().Trim();
var N = int.Parse(line);
line = Console.ReadLine().Trim();
var ArrA = Array.ConvertAll<string, int>(
line.Split(' '), new Converter<string, int>(s => int.Parse(s)));
for (var i = 0; i < N; i++) {
ArrA[i] -= (i + 1);
}
Array.Sort(ArrA);
var ArrB = new int[2];
var exist2patternflg = false;
if (N % 2 == 0) {
ArrB[0] = ArrA[N / 2 - 1];
ArrB[1] = ArrA[N / 2];
exist2patternflg = true;
} else {
ArrB[0] = ArrA[N / 2 - 1];
}
var sumSad = 0L;
for (var i = 0; i < N; i++) {
sumSad += Math.Abs(ArrA[i] - ArrB[0]);
}
WriteLine(sumSad);
return;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass {
static void Main(string[] args) { Answer(); }
public static void Answer() {
var line = Console.ReadLine().Trim();
var N = int.Parse(line);
line = Console.ReadLine().Trim();
var ArrA = Array.ConvertAll<string, int>(
line.Split(' '), new Converter<string, int>(s => int.Parse(s)));
for (var i = 0; i < N; i++) {
ArrA[i] -= (i + 1);
}
Array.Sort(ArrA);
var ArrB = new int[2];
var exist2patternflg = false;
if (N % 2 == 0) {
ArrB[0] = ArrA[N / 2 - 1];
ArrB[1] = ArrA[N / 2];
exist2patternflg = true;
} else {
ArrB[0] = ArrA[N / 2];
}
var sumSad = 0L;
for (var i = 0; i < N; i++) {
sumSad += Math.Abs(ArrA[i] - ArrB[0]);
}
WriteLine(sumSad);
return;
}
}
|
[["-", 12, 204, 206, 207, 0, 28, 0, 16, 17, 33], ["-", 12, 204, 206, 207, 0, 28, 0, 16, 12, 203]]
| 8
| 291
| 2
|
using System;
class Program {
static void Main() {
int s = int.Parse(Console.ReadLine());
int[] q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
double a = 100000000000000;
int c2 = 2, c1 = 1, c3 = 3;
int n1 = q[0], n2 = 0, n3 = q[2] + q[1], n4 = 0;
for (int i = 3; i < s; i++) {
n4 += q[i];
}
for (; c2 < s - 1; c2++) {
n2 += q[c2 - 1];
n3 -= q[c2 - 1];
while (c1 < c2 &&
Math.Abs(n1 - n2) >= Math.Abs((n1 + q[c1]) - (n2 - q[c1]))) {
n1 += q[c1];
n2 -= q[c1];
c1++;
}
while (c3 < s &&
Math.Abs(n3 - n4) >= Math.Abs((n3 + q[c3]) - (n4 - q[c3]))) {
n3 += q[c3];
n4 -= q[c3];
c3++;
}
int[] arr = { n1, n2, n3, n4 };
Array.Sort(arr);
a = Math.Min(a, arr[3] - arr[0]);
}
Console.WriteLine(a);
}
}
|
using System;
class Program {
static void Main() {
int s = int.Parse(Console.ReadLine());
int[] q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
double a = 100000000000000;
int c2 = 2, c1 = 1, c3 = 3;
double n1 = q[0], n2 = 0, n3 = q[2] + q[1], n4 = 0;
for (int i = 3; i < s; i++) {
n4 += q[i];
}
for (; c2 < s - 1; c2++) {
n2 += q[c2 - 1];
n3 -= q[c2 - 1];
while (c1 < c2 &&
Math.Abs(n1 - n2) >= Math.Abs((n1 + q[c1]) - (n2 - q[c1]))) {
n1 += q[c1];
n2 -= q[c1];
c1++;
}
while (c3 < s &&
Math.Abs(n3 - n4) >= Math.Abs((n3 + q[c3]) - (n4 - q[c3]))) {
n3 += q[c3];
n4 -= q[c3];
c3++;
}
double[] arr = { n1, n2, n3, n4 };
Array.Sort(arr);
a = Math.Min(a, arr[3] - arr[0]);
}
Console.WriteLine(a);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199]]
| 8
| 315
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static long Mod = (long)1e9 + 7;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
var N = Sarray()[0];
var A = Slist();
for (var i = 0; i < N; ++i)
A[i] -= i + 1;
A.Sort();
var min = A.Min();
var max = A.Max() + 1;
var rui = new long[N + 1];
for (var i = 1; i <= N; ++i)
rui[i] = rui[i - 1] + A[i - 1];
var ans = long.MaxValue;
while (min < max) {
var mid = min + (max - min) / 2;
var kouho = Calc(mid, rui, A);
var kouhou = Calc(mid + 1, rui, A);
ans = Min(ans, kouho);
if (kouho <= kouhou)
max = mid - 1;
else
min = mid + 1;
}
WriteLine(ans);
// Out.Flush();
}
class lb<T> : IComparer<T>
where T : IComparable<T> {
public int Compare(T x, T y) => 0 <= x.CompareTo(y) ? 1 : -1;
}
static long Calc(long mid, long[] rui, List<long> A) {
var idx = ~A.BinarySearch(mid, new lb<long>());
var N = A.Count;
var r = rui[N] - rui[idx] - mid * (N - idx);
var l = mid * idx - rui[idx];
return r + l;
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder {
class Program {
static public long[] Sarray() {
return ReadLine().Split().Select(long.Parse).ToArray();
}
static public List<long> Slist() {
return ReadLine().Split().Select(long.Parse).ToList();
}
static long Mod = (long)1e9 + 7;
static void Main(string[] args) {
// SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
var N = Sarray()[0];
var A = Slist();
for (var i = 0; i < N; ++i)
A[i] -= i + 1;
A.Sort();
var min = A.Min();
var max = A.Max();
var rui = new long[N + 1];
for (var i = 1; i <= N; ++i)
rui[i] = rui[i - 1] + A[i - 1];
var ans = long.MaxValue;
while (min <= max) {
var mid = min + (max - min) / 2;
var kouho = Calc(mid, rui, A);
var kouhou = Calc(mid + 1, rui, A);
ans = Min(ans, kouho);
if (kouho <= kouhou)
max = mid - 1;
else
min = mid + 1;
}
WriteLine(ans);
// Out.Flush();
}
class lb<T> : IComparer<T>
where T : IComparable<T> {
public int Compare(T x, T y) => 0 <= x.CompareTo(y) ? 1 : -1;
}
static long Calc(long mid, long[] rui, List<long> A) {
var idx = ~A.BinarySearch(mid, new lb<long>());
var N = A.Count;
var r = rui[N] - rui[idx] - mid * (N - idx);
var l = mid * idx - rui[idx];
return r + l;
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19]]
| 8
| 455
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder
{
public class Program
{
static void Main(string[] args)
{
var cin = new Scanner2();
int n = cin.Int();
long[] a = cin.ArrayLong(n);
long sum = a.Sum();
var ruiL = new long[n + 1];
var ruiR = new long[n + 1];
for (int i = 0; i < n; i++) {
ruiL[i + 1] = a[i] + ruiL[i];
ruiR[i + 1] = a[n - 1 - i] + ruiR[i];
}
long ans = sum;
for (int i = 1; i < n - 2; i++) {
long leftSum = ruiL[i + 1];
long rightSum = sum - leftSum;
int li = BinarySearchIntL(0, i, mid => ruiL[mid + 1] <= leftSum / 2);
int ri = BinarySearchIntL(
i + 1, n - i, mid => ruiL[mid + 1] - ruiL[i + 1] <= rightSum / 2);
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {
long l1 = j == 0 || li == i ? ruiL[li + 1] : ruiL[li + 2];
long l2 = leftSum - l1;
long r1 = k == 0 || ri == n - 2
? ruiL[ri + 1] - ruiL[i + 1]
: ruiL[ri + 2] - ruiL[i + 1];
long r2 = rightSum - r1;
long min = Math.Min(l1, Math.Min(l2, Math.Min(r1, r2)));
long max = Math.Max(l1, Math.Max(l2, Math.Max(r1, r2)));
ans = Math.Min(ans, max - min);
}
}
}
Console.WriteLine(ans);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int BinarySearchIntL(int ok, int ng, Func<int, bool> check)
{
while (ng - ok > 1) {
int mid = (ok + ng) / 2;
if (check(mid)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
}
public static class Helper
{
public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
=> array[index] = Math.Min(array[index], value);
public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
=> array[index] = Math.Max(array[index], value);
public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
=> array[index] = Math.Min(array[index], value);
public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
=> array[index] = Math.Max(array[index], value);
public static T[] Array<T>(int n, Func<int, T> init)
=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
public static List<T> List<T>(int n, Func<int, T> init)
=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
private static readonly int[] delta4_ = { 1, 0, -1, 0, 1 };
public static void DoAt4(int i, int j, int imax, int jmax, Action<int, int> action)
{
for (int n = 0; n < 4; n++) {
int ii = i + delta4_[n];
int jj = j + delta4_[n + 1];
if ((uint)ii < (uint)imax && (uint)jj < (uint)jmax) {
action(ii, jj);
}
}
}
}
public class Scanner2
{
private readonly char[] delimiter_ = new char[] { ' ' };
private readonly string filePath_;
private readonly Func<string> reader_;
private string[] buf_;
private int index_;
public Scanner2(string file = "")
{
if (string.IsNullOrWhiteSpace(file)) {
reader_ = Console.ReadLine;
} else {
filePath_ = file;
var fs = new StreamReader(file);
reader_ = fs.ReadLine;
}
buf_ = new string[0];
index_ = 0;
}
public string Next()
{
if (index_ < buf_.Length) {
return buf_[index_++];
}
string st = reader_();
while (st == "") {
st = reader_();
}
buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
if (buf_.Length == 0) {
return Next();
}
index_ = 0;
return buf_[index_++];
}
public int Int() => int.Parse(Next());
public long Long() => long.Parse(Next());
public double Double() => double.Parse(Next());
public int[] ArrayInt(int N, int add = 0)
{
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long[] ArrayLong(int N, long add = 0)
{
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double[] ArrayDouble(int N, double add = 0)
{
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
public void Save(string text)
{
if (string.IsNullOrWhiteSpace(filePath_)) {
return;
}
File.WriteAllText(filePath_ + "_output.txt", text);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AtCorder
{
public class Program
{
static void Main(string[] args)
{
var cin = new Scanner2();
int n = cin.Int();
long[] a = cin.ArrayLong(n);
long sum = a.Sum();
var ruiL = new long[n + 1];
var ruiR = new long[n + 1];
for (int i = 0; i < n; i++) {
ruiL[i + 1] = a[i] + ruiL[i];
ruiR[i + 1] = a[n - 1 - i] + ruiR[i];
}
long ans = sum;
for (int i = 1; i < n - 2; i++) {
long leftSum = ruiL[i + 1];
long rightSum = sum - leftSum;
int li = BinarySearchIntL(0, i, mid => ruiL[mid + 1] <= leftSum / 2);
int ri = BinarySearchIntL(
i + 1, n - 1, mid => ruiL[mid + 1] - ruiL[i + 1] <= rightSum / 2);
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {
long l1 = j == 0 || li == i ? ruiL[li + 1] : ruiL[li + 2];
long l2 = leftSum - l1;
long r1 = k == 0 || ri == n - 2
? ruiL[ri + 1] - ruiL[i + 1]
: ruiL[ri + 2] - ruiL[i + 1];
long r2 = rightSum - r1;
long min = Math.Min(l1, Math.Min(l2, Math.Min(r1, r2)));
long max = Math.Max(l1, Math.Max(l2, Math.Max(r1, r2)));
ans = Math.Min(ans, max - min);
}
}
}
Console.WriteLine(ans);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int BinarySearchIntL(int ok, int ng, Func<int, bool> check)
{
while (ng - ok > 1) {
int mid = (ok + ng) / 2;
if (check(mid)) {
ok = mid;
} else {
ng = mid;
}
}
return ok;
}
}
public static class Helper
{
public static void UpdateMin32<T>(T array, int index, int value) where T : IList<int>
=> array[index] = Math.Min(array[index], value);
public static void UpdateMax32<T>(T array, int index, int value) where T : IList<int>
=> array[index] = Math.Max(array[index], value);
public static void UpdateMin64<T>(T array, int index, long value) where T : IList<long>
=> array[index] = Math.Min(array[index], value);
public static void UpdateMax64<T>(T array, int index, long value) where T : IList<long>
=> array[index] = Math.Max(array[index], value);
public static T[] Array<T>(int n, Func<int, T> init)
=> Enumerable.Range(0, n).Select(x => init(x)).ToArray();
public static List<T> List<T>(int n, Func<int, T> init)
=> Enumerable.Range(0, n).Select(x => init(x)).ToList();
private static readonly int[] delta4_ = { 1, 0, -1, 0, 1 };
public static void DoAt4(int i, int j, int imax, int jmax, Action<int, int> action)
{
for (int n = 0; n < 4; n++) {
int ii = i + delta4_[n];
int jj = j + delta4_[n + 1];
if ((uint)ii < (uint)imax && (uint)jj < (uint)jmax) {
action(ii, jj);
}
}
}
}
public class Scanner2
{
private readonly char[] delimiter_ = new char[] { ' ' };
private readonly string filePath_;
private readonly Func<string> reader_;
private string[] buf_;
private int index_;
public Scanner2(string file = "")
{
if (string.IsNullOrWhiteSpace(file)) {
reader_ = Console.ReadLine;
} else {
filePath_ = file;
var fs = new StreamReader(file);
reader_ = fs.ReadLine;
}
buf_ = new string[0];
index_ = 0;
}
public string Next()
{
if (index_ < buf_.Length) {
return buf_[index_++];
}
string st = reader_();
while (st == "") {
st = reader_();
}
buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
if (buf_.Length == 0) {
return Next();
}
index_ = 0;
return buf_[index_++];
}
public int Int() => int.Parse(Next());
public long Long() => long.Parse(Next());
public double Double() => double.Parse(Next());
public int[] ArrayInt(int N, int add = 0)
{
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Int() + add;
}
return Array;
}
public long[] ArrayLong(int N, long add = 0)
{
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = Long() + add;
}
return Array;
}
public double[] ArrayDouble(int N, double add = 0)
{
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = Double() + add;
}
return Array;
}
public void Save(string text)
{
if (string.IsNullOrWhiteSpace(filePath_)) {
return;
}
File.WriteAllText(filePath_ + "_output.txt", text);
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 1,367
| 2
|
using System;
namespace ABC101A {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int i = 0;
for (int a = 0; a < 4; a++) {
int y = 0;
y = y + i;
if (s.Substring(y, 1) == "+")
i = i + 1;
else
i = i - 1;
}
Console.WriteLine(i);
Console.ReadKey();
}
}
}
|
using System;
namespace ABC101A {
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
int i = 0;
for (int a = 0; a < 4; a++) {
int y = 0;
y = y + a;
if (s.Substring(y, 1) == "+") {
i = i + 1;
} else {
i = i - 1;
}
}
Console.WriteLine(i);
Console.ReadKey();
}
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46]]
| 8
| 104
| 6
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace FertiLib.Contest.B {
static class Program {
public static void Solve(Scanner cin) {
int n = cin.ReadInt();
YesNo(n / n.ToString().Select(x => int.Parse(x.ToString())).Sum() == 0);
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
Solve(cin);
Console.Out.Flush();
}
public static void
YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO");
public static void
YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No");
public static void
yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no");
public static bool Chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) >= 0)
return false;
a = b;
return true;
}
public static bool Chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) <= 0)
return false;
a = b;
return true;
}
}
static class Util {
public static string
Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
}
class Scanner {
string[] s;
int i;
char[] separator = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Read() => ReadString();
public string ReadString() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return ReadString();
i = 0;
return s[i++];
}
public string[] ReadStringArray(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadString();
}
return Array;
}
public int ReadInt() { return int.Parse(ReadString()); }
public int[] ReadIntArray(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadInt() + add;
}
return Array;
}
public long ReadLong() { return long.Parse(ReadString()); }
public long[] ReadLongArray(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadLong() + add;
}
return Array;
}
public double ReadDouble() { return double.Parse(ReadString()); }
public double[] ReadDoubleArray(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadDouble() + add;
}
return Array;
}
public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(),
typeof(T1));
public (T1, T2) ReadValue<T1, T2>() {
var inputs = ReadStringArray(2);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
return (v1, v2);
}
public (T1, T2, T3) ReadValue<T1, T2, T3>() {
var inputs = ReadStringArray(3);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
return (v1, v2, v3);
}
public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
var inputs = ReadStringArray(4);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
return (v1, v2, v3, v4);
}
public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() {
var inputs = ReadStringArray(5);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
return (v1, v2, v3, v4, v5);
}
public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() {
var inputs = ReadStringArray(6);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
return (v1, v2, v3, v4, v5, v6);
}
public (T1, T2, T3, T4, T5, T6,
T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() {
var inputs = ReadStringArray(7);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
return (v1, v2, v3, v4, v5, v6, v7);
}
public T1[] ReadValueArray<T1>(int N) {
var v1 = new T1[N];
for (int i = 0; i < N; i++) {
v1[i] = ReadValue<T1>();
}
return v1;
}
public (T1[], T2[]) ReadValueArray<T1, T2>(int N) {
var (v1, v2) = (new T1[N], new T2[N]);
for (int i = 0; i < N; i++) {
var (t1, t2) = ReadValue<T1, T2>();
v1[i] = t1;
v2[i] = t2;
}
return (v1, v2);
}
public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) {
var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3) = ReadValue<T1, T2, T3>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
}
return (v1, v2, v3);
}
public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) {
var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
}
return (v1, v2, v3, v4);
}
public (T1[], T2[], T3[], T4[],
T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) {
var (v1, v2, v3, v4, v5) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
}
return (v1, v2, v3, v4, v5);
}
public (T1[], T2[], T3[], T4[], T5[],
T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) {
var (v1, v2, v3, v4, v5, v6) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
}
return (v1, v2, v3, v4, v5, v6);
}
public (T1[], T2[], T3[], T4[], T5[], T6[],
T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) {
var (v1, v2, v3, v4, v5, v6, v7) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N],
new T7[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6, t7) =
ReadValue<T1, T2, T3, T4, T5, T6, T7>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
v7[i] = t7;
}
return (v1, v2, v3, v4, v5, v6, v7);
}
}
}
|
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
namespace FertiLib.Contest.B {
static class Program {
public static void Solve(Scanner cin) {
int n = cin.ReadInt();
YesNo(n % n.ToString().Select(x => int.Parse(x.ToString())).Sum() == 0);
}
public static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var cin = new Scanner();
Solve(cin);
Console.Out.Flush();
}
public static void
YESNO(bool condition) => Console.WriteLine(condition ? "YES" : "NO");
public static void
YesNo(bool condition) => Console.WriteLine(condition ? "Yes" : "No");
public static void
yesno(bool condition) => Console.WriteLine(condition ? "yes" : "no");
public static bool Chmax<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) >= 0)
return false;
a = b;
return true;
}
public static bool Chmin<T>(ref T a, T b)
where T : IComparable<T> {
if (a.CompareTo(b) <= 0)
return false;
a = b;
return true;
}
}
static class Util {
public static string
Join<T>(this IEnumerable<T> x,
string separator = "") => string.Join(separator, x);
}
class Scanner {
string[] s;
int i;
char[] separator = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Read() => ReadString();
public string ReadString() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(separator, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return ReadString();
i = 0;
return s[i++];
}
public string[] ReadStringArray(int N) {
string[] Array = new string[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadString();
}
return Array;
}
public int ReadInt() { return int.Parse(ReadString()); }
public int[] ReadIntArray(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadInt() + add;
}
return Array;
}
public long ReadLong() { return long.Parse(ReadString()); }
public long[] ReadLongArray(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadLong() + add;
}
return Array;
}
public double ReadDouble() { return double.Parse(ReadString()); }
public double[] ReadDoubleArray(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = ReadDouble() + add;
}
return Array;
}
public T1 ReadValue<T1>() => (T1)Convert.ChangeType(ReadString(),
typeof(T1));
public (T1, T2) ReadValue<T1, T2>() {
var inputs = ReadStringArray(2);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
return (v1, v2);
}
public (T1, T2, T3) ReadValue<T1, T2, T3>() {
var inputs = ReadStringArray(3);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
return (v1, v2, v3);
}
public (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
var inputs = ReadStringArray(4);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
return (v1, v2, v3, v4);
}
public (T1, T2, T3, T4, T5) ReadValue<T1, T2, T3, T4, T5>() {
var inputs = ReadStringArray(5);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
return (v1, v2, v3, v4, v5);
}
public (T1, T2, T3, T4, T5, T6) ReadValue<T1, T2, T3, T4, T5, T6>() {
var inputs = ReadStringArray(6);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
return (v1, v2, v3, v4, v5, v6);
}
public (T1, T2, T3, T4, T5, T6,
T7) ReadValue<T1, T2, T3, T4, T5, T6, T7>() {
var inputs = ReadStringArray(7);
var v1 = (T1)Convert.ChangeType(inputs[0], typeof(T1));
var v2 = (T2)Convert.ChangeType(inputs[1], typeof(T2));
var v3 = (T3)Convert.ChangeType(inputs[2], typeof(T3));
var v4 = (T4)Convert.ChangeType(inputs[3], typeof(T4));
var v5 = (T5)Convert.ChangeType(inputs[4], typeof(T5));
var v6 = (T6)Convert.ChangeType(inputs[5], typeof(T6));
var v7 = (T7)Convert.ChangeType(inputs[6], typeof(T7));
return (v1, v2, v3, v4, v5, v6, v7);
}
public T1[] ReadValueArray<T1>(int N) {
var v1 = new T1[N];
for (int i = 0; i < N; i++) {
v1[i] = ReadValue<T1>();
}
return v1;
}
public (T1[], T2[]) ReadValueArray<T1, T2>(int N) {
var (v1, v2) = (new T1[N], new T2[N]);
for (int i = 0; i < N; i++) {
var (t1, t2) = ReadValue<T1, T2>();
v1[i] = t1;
v2[i] = t2;
}
return (v1, v2);
}
public (T1[], T2[], T3[]) ReadValueArray<T1, T2, T3>(int N) {
var (v1, v2, v3) = (new T1[N], new T2[N], new T3[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3) = ReadValue<T1, T2, T3>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
}
return (v1, v2, v3);
}
public (T1[], T2[], T3[], T4[]) ReadValueArray<T1, T2, T3, T4>(int N) {
var (v1, v2, v3, v4) = (new T1[N], new T2[N], new T3[N], new T4[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4) = ReadValue<T1, T2, T3, T4>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
}
return (v1, v2, v3, v4);
}
public (T1[], T2[], T3[], T4[],
T5[]) ReadValueArray<T1, T2, T3, T4, T5>(int N) {
var (v1, v2, v3, v4, v5) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5) = ReadValue<T1, T2, T3, T4, T5>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
}
return (v1, v2, v3, v4, v5);
}
public (T1[], T2[], T3[], T4[], T5[],
T6[]) ReadValueArray<T1, T2, T3, T4, T5, T6>(int N) {
var (v1, v2, v3, v4, v5, v6) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6) = ReadValue<T1, T2, T3, T4, T5, T6>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
}
return (v1, v2, v3, v4, v5, v6);
}
public (T1[], T2[], T3[], T4[], T5[], T6[],
T7[]) ReadValueArray<T1, T2, T3, T4, T5, T6, T7>(int N) {
var (v1, v2, v3, v4, v5, v6, v7) =
(new T1[N], new T2[N], new T3[N], new T4[N], new T5[N], new T6[N],
new T7[N]);
for (int i = 0; i < N; i++) {
var (t1, t2, t3, t4, t5, t6, t7) =
ReadValue<T1, T2, T3, T4, T5, T6, T7>();
v1[i] = t1;
v2[i] = t2;
v3[i] = t3;
v4[i] = t4;
v5[i] = t5;
v6[i] = t6;
v7[i] = t7;
}
return (v1, v2, v3, v4, v5, v6, v7);
}
}
}
|
[["-", 3, 4, 0, 28, 0, 16, 31, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 31, 16, 17, 109]]
| 8
| 2,660
| 2
|
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();
}
public static bool judge(long n) {
var keta = new List<long>();
long tmp = n;
while (tmp > 0) {
keta.Add(n % 10);
tmp /= 10;
}
var sum = keta.Sum();
if (n % sum == 0)
return true;
else
return false;
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
if (judge(n))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
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();
}
public static bool judge(long n) {
var keta = new List<long>();
long tmp = n;
while (tmp > 0) {
keta.Add(tmp % 10);
tmp /= 10;
}
var sum = keta.Sum();
if (n % sum == 0)
return true;
else
return false;
}
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var n = Read();
if (judge(n))
Console.WriteLine("Yes");
else
Console.WriteLine("No");
Console.Out.Flush();
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 31, 22]]
| 8
| 228
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp35 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
// Sの桁数
int S_len = S.Length;
int sum = 0;
for (int i = 0; i < S_len; i++) {
sum += int.Parse(S[i].ToString());
}
// Console.WriteLine(sum);
if (int.Parse(S) % sum == 0) {
Console.WriteLine("YES");
} else {
Console.WriteLine("NO");
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp35 {
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
// Sの桁数
int S_len = S.Length;
int sum = 0;
for (int i = 0; i < S_len; i++) {
sum += int.Parse(S[i].ToString());
}
// Console.WriteLine(sum);
if (int.Parse(S) % sum == 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 137
| 4
|
using System;
using System.Linq;
class Program {
static void Main() {
uint N = uint.Parse(Console.ReadLine());
uint n = N;
uint sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
bool res = N % sum == 0;
Console.WriteLine(res ? "YES" : "NO");
}
}
|
using System;
using System.Linq;
class Program {
static void Main() {
uint N = uint.Parse(Console.ReadLine());
uint n = N;
uint sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
bool res = N % sum == 0;
Console.WriteLine(res ? "Yes" : "No");
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["-", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 85
| 4
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
int X = int.Parse(Console.ReadLine());
int Y = 0;
int T = X;
if (T > 0) {
Y += T % 10;
T = T / 10;
}
if (X % Y == 0)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
int X = int.Parse(Console.ReadLine());
int Y = 0;
int T = X;
while (T > 0) {
Y += T % 10;
T = T / 10;
}
if (X % Y == 0)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["+", 8, 201, 0, 195, 8, 196, 0, 52, 0, 89]]
| 8
| 93
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long s = 0;
long NN = N;
for (int i = 0; i < 9; i++) {
s += NN % 10;
NN /= 10;
}
if (N % s == 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
long s = 0;
long NN = N;
for (int i = 0; i < 10; i++) {
s += NN % 10;
NN /= 10;
}
if (N % s == 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 111
| 2
|
using System;
public class Hello {
public static void Main() {
var n = int.Parse(Console.ReadLine().Trim());
var s = n.ToString();
var sum = 0;
for (int i = 0; i < s.Length; i++) {
sum += int.Parse(s[i].ToString());
}
if (sum % n == 0)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
using System;
public class Hello {
public static void Main() {
var n = int.Parse(Console.ReadLine().Trim());
var s = n.ToString();
var sum = 0;
for (int i = 0; i < s.Length; i++) {
sum += int.Parse(s[i].ToString());
}
if (n % sum == 0)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 31, 22], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22]]
| 8
| 109
| 4
|
using System;
namespace c {
class MainClass {
public static void Main(string[] args) {
string[] NK = Console.ReadLine().Split(' ');
string[] A = Console.ReadLine().Split(' ');
int N = int.Parse(NK[0]);
int K = int.Parse(NK[1]);
if (K - 1 == 1) {
Console.WriteLine(N - 1);
} else {
int count = 0;
while (N > 0) {
N = N - (K - 1);
count++;
}
Console.WriteLine(count);
}
}
}
}
|
using System;
namespace c {
class MainClass {
public static void Main(string[] args) {
string[] NK = Console.ReadLine().Split(' ');
string[] A = Console.ReadLine().Split(' ');
int N = int.Parse(NK[0]);
int K = int.Parse(NK[1]);
if (K - 1 == 1) {
Console.WriteLine(N - 1);
} else {
int count = 0;
N = N - 1;
while (N > 0) {
N = N - (K - 1);
count++;
}
Console.WriteLine(count);
}
}
}
}
|
[["+", 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, 16, 31, 22], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 140
| 6
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static void Main(string[] args) {
//入力を受け取る
var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int N = NK[0];
int K = NK[1];
var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var L = K - 1;
var min = 1;
var point1 = 0;
var count = 0;
var res = 0;
if (N % L == 0) {
res = N / L;
} else {
res = N / L + 1;
}
Console.WriteLine(res);
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
class Program {
static void Main(string[] args) {
//入力を受け取る
var NK = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
int N = NK[0];
N = N - 1;
int K = NK[1];
var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var L = K - 1;
var min = 1;
var point1 = 0;
var count = 0;
var res = 0;
if (N % L == 0) {
res = N / L;
} else {
res = N / L + 1;
}
Console.WriteLine(res);
}
}
|
[["+", 0, 195, 8, 196, 0, 1, 0, 11, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["+", 8, 201, 0, 195, 8, 196, 0, 1, 0, 35]]
| 8
| 186
| 6
|
using System;
class ProblemC {
static void Main() {
string[] s = Console.ReadLine().Split(' ');
Console.ReadLine();
int N = int.Parse(s[0]);
int K = int.Parse(s[1]);
Console.WriteLine((N - 1) / (K - 1));
}
}
|
using System;
class ProblemC {
static void Main() {
string[] s = Console.ReadLine().Split(' ');
Console.ReadLine();
int N = int.Parse(s[0]);
int K = int.Parse(s[1]);
Console.WriteLine((N - 2) / (K - 1) + 1);
}
}
|
[["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 81
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc101_c {
class Program {
static void Main(string[] args) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
int n = input[0];
int k = input[1];
int[] arr = ReadLine().Split().Select(int.Parse).ToArray();
int min = int.MaxValue;
int p = 0;
double cnt = 0;
for (int i = 0; i < arr.Length; i++) {
if (min >= arr[i]) {
p = i;
min = arr[i];
}
}
if (k == 2) {
cnt = n - 1;
} else {
cnt = (double)(n - p - 1) / (k - 1) + (double)p / k;
}
WriteLine(Ceiling(cnt));
}
/// 値のスワップ
static void Swap<T>(ref T lhs, ref T rhs) {
T temp;
temp = lhs;
lhs = rhs;
rhs = temp;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;
namespace abc101_c {
class Program {
static void Main(string[] args) {
int[] input = ReadLine().Split().Select(int.Parse).ToArray();
int n = input[0];
int k = input[1];
int[] arr = ReadLine().Split().Select(int.Parse).ToArray();
int min = int.MaxValue;
int p = 0;
double cnt = 0;
for (int i = 0; i < arr.Length; i++) {
if (min >= arr[i]) {
p = i;
min = arr[i];
}
}
if (k == 2) {
cnt = n - 1;
} else {
cnt = (double)(n - p - 1) / (k - 1) + (double)p / (k - 1);
}
WriteLine(Ceiling(cnt));
}
/// 値のスワップ
static void Swap<T>(ref T lhs, ref T rhs) {
T temp;
temp = lhs;
lhs = rhs;
rhs = temp;
}
}
}
|
[["+", 0, 11, 12, 16, 12, 16, 12, 23, 0, 24], ["+", 12, 16, 12, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 16, 12, 16, 12, 23, 0, 16, 12, 203], ["+", 0, 11, 12, 16, 12, 16, 12, 23, 0, 25]]
| 8
| 276
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtcoderTemplateForCSharp {
public class Program {
public static void Main(string[] args) {
var s = Console.ReadLine();
var n = int.Parse(s.Split(' ').First());
var k = int.Parse(s.Split(' ').Last());
var tmp = Console.ReadLine();
if (n == k) {
Console.WriteLine(1);
} else {
if (n - 1 % (k - 1) == 0) {
Console.WriteLine((n - 1) / (k - 1));
} else {
Console.WriteLine((n - 1) / (k - 1) + 1);
}
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtcoderTemplateForCSharp {
public class Program {
public static void Main(string[] args) {
var s = Console.ReadLine();
var n = int.Parse(s.Split(' ').First());
var k = int.Parse(s.Split(' ').Last());
var tmp = Console.ReadLine();
if (n == k) {
Console.WriteLine(1);
} else {
if ((n - 1) % (k - 1) == 0) {
Console.WriteLine((n - 1) / (k - 1));
} else {
Console.WriteLine((n - 1) / (k - 1) + 1);
}
}
}
}
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 24], ["+", 0, 57, 15, 16, 31, 16, 31, 23, 0, 25]]
| 8
| 181
| 2
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
string ss = Console.ReadLine();
a -= b;
int buf = 1;
while (a >= 0) {
a -= b - 1;
buf++;
}
Console.WriteLine(buf);
}
}
}
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int a = int.Parse(s[0]);
int b = int.Parse(s[1]);
string ss = Console.ReadLine();
a -= b;
int buf = 1;
while (a > 0) {
a -= b - 1;
buf++;
}
Console.WriteLine(buf);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 20], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 47]]
| 8
| 108
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;
using E = System.Linq.Enumerable;
internal partial class Solver {
public void Run() {
var n = ni();
var cands = new List<long>();
var ten = new long[18];
ten[0] = 1;
for (int i = 1; i < ten.Length; i++) {
ten[i] = ten[i - 1] * 10;
}
for (int trailing9 = 0; trailing9 <= 15; trailing9++) {
for (int b = 1; b <= 200; b++) {
if (b % 10 == 9)
continue;
var v = b * ten[trailing9] + ten[trailing9] - 1;
if (v <= 2 * 1e15) {
cands.Add(v);
}
}
}
cands.Sort();
decimal minV = 1e18m;
for (int i = cands.Count - 1; i >= 0; i--) {
var v = cands[i] * 1m / DigitNum(cands[i]);
if (v > minV) {
cands[i] = -1;
}
if (minV > v) {
minV = v;
}
}
cands.RemoveAll(x => x == -1);
cout.WriteLine(string.Join("\n", cands.Take(n)));
}
long DigitNum(long n) {
var d = 0L;
while (n > 0) {
d += n % 10;
n /= 10;
}
return d;
}
}
// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
public static void Main() {
#if LOCAL
byte[] inputBuffer = new byte[1000000];
var inputStream = Console.OpenStandardInput(inputBuffer.Length);
using (var reader = new StreamReader(inputStream, Console.InputEncoding,
false, inputBuffer.Length)) {
Console.SetIn(reader);
new Solver(Console.In, Console.Out).Run();
}
#else
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver(Console.In, Console.Out).Run();
Console.Out.Flush();
#endif
}
#pragma warning disable IDE0052
private readonly TextReader cin;
private readonly TextWriter cout;
#pragma warning restore IDE0052
public Solver(TextReader reader, TextWriter writer) : base(reader) {
cin = reader;
cout = writer;
}
public Solver(string input, TextWriter writer)
: this(new StringReader(input), writer) {}
#pragma warning disable IDE1006
#pragma warning disable IDE0051
private int ni() { return NextInt(); }
private int[] ni(int n) { return NextIntArray(n); }
private long nl() { return NextLong(); }
private long[] nl(int n) { return NextLongArray(n); }
private double nd() { return NextDouble(); }
private double[] nd(int n) { return NextDoubleArray(n); }
private string ns() { return Next(); }
private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}
internal static class LinqPadExtension {
[Conditional("DEBUG")]
public static void Dump<T>(this T obj) {
#if DEBUG
LINQPad.Extensions.Dump(obj);
#endif
}
}
public class Scanner {
private readonly TextReader Reader;
private readonly CultureInfo ci = CultureInfo.InvariantCulture;
private readonly char[] buffer = new char[2 * 1024];
private int cursor = 0, length = 0;
private string Token;
private readonly StringBuilder sb = new StringBuilder(1024);
public Scanner() : this(Console.In) {}
public Scanner(TextReader reader) { Reader = reader; }
public int NextInt() { return checked((int)NextLong()); }
public long NextLong() {
var s = Next();
long r = 0;
int i = 0;
bool negative = false;
if (s[i] == '-') {
negative = true;
i++;
}
for (; i < s.Length; i++) {
r = r * 10 + (s[i] - '0');
#if DEBUG
if (!char.IsDigit(s[i]))
throw new FormatException();
#endif
}
return negative ? -r : r;
}
public double NextDouble() { return double.Parse(Next(), ci); }
public string[] NextArray(int size) {
string[] array = new string[size];
for (int i = 0; i < size; i++) {
array[i] = Next();
}
return array;
}
public int[] NextIntArray(int size) {
int[] array = new int[size];
for (int i = 0; i < size; i++) {
array[i] = NextInt();
}
return array;
}
public long[] NextLongArray(int size) {
long[] array = new long[size];
for (int i = 0; i < size; i++) {
array[i] = NextLong();
}
return array;
}
public double[] NextDoubleArray(int size) {
double[] array = new double[size];
for (int i = 0; i < size; i++) {
array[i] = NextDouble();
}
return array;
}
public string Next() {
if (Token == null) {
if (!StockToken()) {
throw new Exception();
}
}
var token = Token;
Token = null;
return token;
}
public bool HasNext() {
if (Token != null) {
return true;
}
return StockToken();
}
private bool StockToken() {
while (true) {
sb.Clear();
while (true) {
if (cursor >= length) {
cursor = 0;
if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) {
break;
}
}
var c = buffer[cursor++];
if (33 <= c && c <= 126) {
sb.Append(c);
} else {
if (sb.Length > 0)
break;
}
}
if (sb.Length > 0) {
Token = sb.ToString();
return true;
}
return false;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;
using E = System.Linq.Enumerable;
internal partial class Solver {
public void Run() {
var n = ni();
var cands = new List<long>();
var ten = new long[18];
ten[0] = 1;
for (int i = 1; i < ten.Length; i++) {
ten[i] = ten[i - 1] * 10;
}
for (int trailing9 = 0; trailing9 <= 15; trailing9++) {
for (int b = 0; b <= 200; b++) {
if (b % 10 == 9)
continue;
var v = b * ten[trailing9] + ten[trailing9] - 1;
if (v > 0 && v <= 2 * 1e15) {
cands.Add(v);
}
}
}
cands.Sort();
decimal minV = 1e18m;
for (int i = cands.Count - 1; i >= 0; i--) {
var v = cands[i] * 1m / DigitNum(cands[i]);
if (v > minV) {
cands[i] = -1;
}
if (minV > v) {
minV = v;
}
}
cands.RemoveAll(x => x == -1);
cout.WriteLine(string.Join("\n", cands.Take(n)));
}
long DigitNum(long n) {
var d = 0L;
while (n > 0) {
d += n % 10;
n /= 10;
}
return d;
}
}
// PREWRITEN CODE BEGINS FROM HERE
internal partial class Solver : Scanner {
public static void Main() {
#if LOCAL
byte[] inputBuffer = new byte[1000000];
var inputStream = Console.OpenStandardInput(inputBuffer.Length);
using (var reader = new StreamReader(inputStream, Console.InputEncoding,
false, inputBuffer.Length)) {
Console.SetIn(reader);
new Solver(Console.In, Console.Out).Run();
}
#else
Console.SetOut(
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
new Solver(Console.In, Console.Out).Run();
Console.Out.Flush();
#endif
}
#pragma warning disable IDE0052
private readonly TextReader cin;
private readonly TextWriter cout;
#pragma warning restore IDE0052
public Solver(TextReader reader, TextWriter writer) : base(reader) {
cin = reader;
cout = writer;
}
public Solver(string input, TextWriter writer)
: this(new StringReader(input), writer) {}
#pragma warning disable IDE1006
#pragma warning disable IDE0051
private int ni() { return NextInt(); }
private int[] ni(int n) { return NextIntArray(n); }
private long nl() { return NextLong(); }
private long[] nl(int n) { return NextLongArray(n); }
private double nd() { return NextDouble(); }
private double[] nd(int n) { return NextDoubleArray(n); }
private string ns() { return Next(); }
private string[] ns(int n) { return NextArray(n); }
#pragma warning restore IDE1006
#pragma warning restore IDE0051
}
internal static class LinqPadExtension {
[Conditional("DEBUG")]
public static void Dump<T>(this T obj) {
#if DEBUG
LINQPad.Extensions.Dump(obj);
#endif
}
}
public class Scanner {
private readonly TextReader Reader;
private readonly CultureInfo ci = CultureInfo.InvariantCulture;
private readonly char[] buffer = new char[2 * 1024];
private int cursor = 0, length = 0;
private string Token;
private readonly StringBuilder sb = new StringBuilder(1024);
public Scanner() : this(Console.In) {}
public Scanner(TextReader reader) { Reader = reader; }
public int NextInt() { return checked((int)NextLong()); }
public long NextLong() {
var s = Next();
long r = 0;
int i = 0;
bool negative = false;
if (s[i] == '-') {
negative = true;
i++;
}
for (; i < s.Length; i++) {
r = r * 10 + (s[i] - '0');
#if DEBUG
if (!char.IsDigit(s[i]))
throw new FormatException();
#endif
}
return negative ? -r : r;
}
public double NextDouble() { return double.Parse(Next(), ci); }
public string[] NextArray(int size) {
string[] array = new string[size];
for (int i = 0; i < size; i++) {
array[i] = Next();
}
return array;
}
public int[] NextIntArray(int size) {
int[] array = new int[size];
for (int i = 0; i < size; i++) {
array[i] = NextInt();
}
return array;
}
public long[] NextLongArray(int size) {
long[] array = new long[size];
for (int i = 0; i < size; i++) {
array[i] = NextLong();
}
return array;
}
public double[] NextDoubleArray(int size) {
double[] array = new double[size];
for (int i = 0; i < size; i++) {
array[i] = NextDouble();
}
return array;
}
public string Next() {
if (Token == null) {
if (!StockToken()) {
throw new Exception();
}
}
var token = Token;
Token = null;
return token;
}
public bool HasNext() {
if (Token != null) {
return true;
}
return StockToken();
}
private bool StockToken() {
while (true) {
sb.Clear();
while (true) {
if (cursor >= length) {
cursor = 0;
if ((length = Reader.Read(buffer, 0, buffer.Length)) <= 0) {
break;
}
}
var c = buffer[cursor++];
if (33 <= c && c <= 126) {
sb.Append(c);
} else {
if (sb.Length > 0)
break;
}
}
if (sb.Length > 0) {
Token = sb.ToString();
return true;
}
return false;
}
}
}
|
[["-", 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, 31, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 1,354
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Practice {
class Program {
static void Main(string[] args) {
// SolveA(args);
// SolveB(args);
// SolveC(args);
SolveD(args);
}
static void SolveA(string[] args) {
string sz = (Console.ReadLine());
int num = 0;
for (int i = 0; i < sz.Length; ++i) {
char c = sz[i];
if (c == '+') {
num++;
} else {
num--;
}
}
Console.WriteLine(num);
}
static void SolveB(string[] args) {
string sz = Console.ReadLine();
long n = long.Parse(sz);
int sn = 0;
for (int i = 0; i < sz.Length; ++i) {
int tmp = int.Parse(sz[i].ToString());
sn += tmp;
}
if (n % sn == 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
static void SolveC(string[] args) {
string[] szArr = Console.ReadLine().Split(' ');
int n = int.Parse(szArr[0]);
int k = int.Parse(szArr[1]);
szArr = Console.ReadLine().Split(' ');
int[] a = new int[szArr.Length];
for (int i = 0; i < szArr.Length; ++i) {
a[i] = int.Parse(szArr[i]);
}
int min = 1;
if (n == k) {
min = 1;
} else {
min = (int)Math.Ceiling((double)(n - 1) / (k - 1));
}
Console.WriteLine(min);
}
static void SolveD(string[] args) {
long k = long.Parse(Console.ReadLine());
long n = 1;
long sunukeTotal = 0;
long prevSunuke = 0;
// とりあえず1~9は確定
while (sunukeTotal < k && n <= 9) {
sunukeTotal++;
prevSunuke = n;
Console.WriteLine(n);
n++;
}
while (sunukeTotal < k) {
long fn = Func(n);
Console.WriteLine(fn);
n = fn;
sunukeTotal++;
}
}
/// <summary>
/// n以上の整数mであってm/S(m)を最小にするもの(複数ある場合は、そのうちmが最小になるもの
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
private static long Func(long n) {
long fn = long.MaxValue;
double minVal = double.MaxValue;
int d = (int)Math.Log10(n) + 1; // todo 精度大丈夫?
for (int di = 0; di <= d; ++di) {
long tmp = (long)Math.Pow(10, di + 1);
long x = tmp * (long)Math.Floor((double)n / tmp + 1) - 1;
double val = (double)x / Sum(x);
if (val < minVal) {
minVal = val;
fn = x;
}
}
return fn;
}
private static long Sum(long x) {
long sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Practice {
class Program {
static void Main(string[] args) {
// SolveA(args);
// SolveB(args);
// SolveC(args);
SolveD(args);
}
static void SolveA(string[] args) {
string sz = (Console.ReadLine());
int num = 0;
for (int i = 0; i < sz.Length; ++i) {
char c = sz[i];
if (c == '+') {
num++;
} else {
num--;
}
}
Console.WriteLine(num);
}
static void SolveB(string[] args) {
string sz = Console.ReadLine();
long n = long.Parse(sz);
int sn = 0;
for (int i = 0; i < sz.Length; ++i) {
int tmp = int.Parse(sz[i].ToString());
sn += tmp;
}
if (n % sn == 0) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
static void SolveC(string[] args) {
string[] szArr = Console.ReadLine().Split(' ');
int n = int.Parse(szArr[0]);
int k = int.Parse(szArr[1]);
szArr = Console.ReadLine().Split(' ');
int[] a = new int[szArr.Length];
for (int i = 0; i < szArr.Length; ++i) {
a[i] = int.Parse(szArr[i]);
}
int min = 1;
if (n == k) {
min = 1;
} else {
min = (int)Math.Ceiling((double)(n - 1) / (k - 1));
}
Console.WriteLine(min);
}
static void SolveD(string[] args) {
long k = long.Parse(Console.ReadLine());
long n = 1;
long sunukeTotal = 0;
long prevSunuke = 0;
// とりあえず1~9は確定
while (sunukeTotal < k && n <= 9) {
sunukeTotal++;
prevSunuke = n;
Console.WriteLine(n);
n++;
}
while (sunukeTotal < k) {
long fn = ClacSunuke(n);
Console.WriteLine(fn);
n = fn + 1;
sunukeTotal++;
}
}
/// <summary>
/// n以上の整数mであってm/S(m)を最小にするもの(複数ある場合は、そのうちmが最小になるもの
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
private static long ClacSunuke(long n) {
long fn = long.MaxValue;
double minVal = double.MaxValue;
int d = (int)Math.Log10(n) + 1; // todo 精度大丈夫?
for (int di = 0; di <= d; ++di) {
long tmp = (long)Math.Pow(10, di + 1);
long x = tmp * (long)Math.Floor((double)n / tmp + 1) - 1;
double val = (double)x / Sum(x);
if (val < minVal) {
minVal = val;
fn = x;
}
}
return fn;
}
private static long Sum(long x) {
long sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 213, 63, 22], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203], ["-", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22], ["+", 8, 201, 0, 235, 8, 201, 0, 195, 141, 22]]
| 8
| 676
| 6
|
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 nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
WriteLine((nk[0] - 1) / (nk[1] - 1) +
ToInt32((nk[0] - 1) % (nk[1] - 1) != 1));
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
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 nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
WriteLine((nk[0] - 1) / (nk[1] - 1) +
ToInt32((nk[0] - 1) % (nk[1] - 1) != 0));
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
[["-", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 12, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 162
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
// using System.Numerics; //comment out if AOJ
using System.Text;
using Problem = Tmp.Problem;
using MyIO;
#pragma warning disable // for AOJ
namespace Tmp {
class Problem : IDisposable {
bool IsGCJ;
int Repeat;
Scanner sc;
Printer pr;
public Problem(bool isGCJ, Scanner scanner, Printer printer) {
sc = scanner;
pr = printer;
IsGCJ = isGCJ;
if (isGCJ)
Repeat = sc.nextInt();
else
Read();
}
public Problem(bool isGCJ) : this(isGCJ, new Scanner(), new Printer()) {}
public Problem(bool isGCJ, Scanner scanner)
: this(isGCJ, scanner, new Printer()) {}
public Problem(bool isGCJ, Printer printer)
: this(isGCJ, new Scanner(), printer) {}
public void Solve() {
if (IsGCJ)
for (var i = 0; i < Repeat; i++) {
Read();
pr.Write("Case #" + (i + 1) + ": ");
SolveOne();
}
else
SolveOne();
}
public void Dispose() {
sc.Dispose();
pr.Dispose();
}
public int Size {
get { return 1; }
}
public const long Mod = 1000000007;
// 使用する変数をここに書く
// string S;
// int a;
/// <summary>
/// 読み込み処理をここに書く
/// </summary>
void Read() {}
/// <summary>
/// メイン処理をここに書く
/// </summary>
void SolveOne() {
long k = sc.nextLong();
HashSet<long> set = new HashSet<long>();
for (int i = 1; i < 10; i++) {
set.Add(i);
}
long keta = 10;
while (keta < 10e16) {
for (int i = 1; i < 1000; i++) {
set.Add(i * keta - 1);
}
keta *= 10;
}
long[] numls = set.ToArray();
double[] scorels = new double[numls.Length];
for (int i = 0; i < numls.Length; i++) {
scorels[i] = SnukeNumCalc(numls[i]);
}
List<long> ans = new List<long>();
double scoreMin = double.MaxValue / 3;
for (int i = numls.Length - 1; i >= 0; i--) {
if (scorels[i] <= scoreMin) {
ans.Add(numls[i]);
scoreMin = scorels[i];
}
}
ans.Reverse();
for (int i = 0; i < k; i++) {
Console.WriteLine(ans[i]);
}
}
long ketaSumCalc(long n) {
long ret = 0;
while (n > 0) {
ret += n % 10;
n /= 10;
}
return ret;
}
double SnukeNumCalc(long n) { return (double)n / ketaSumCalc(n); }
}
}
class Program {
// public static RandomSFMT rand = new RandomSFMT();
public static bool IsJudgeMode = true;
public static bool IsGCJMode = false;
public static bool IsSolveCreated = true;
static void Main() {
if (IsJudgeMode)
if (IsGCJMode)
using (var problem =
new Problem(true, new Scanner("C-large-practice.in.txt"),
new Printer("output.txt"))) problem.Solve();
else
using (var problem = new Problem(false, new Printer())) problem.Solve();
else {
var num = 1;
int size = 0;
decimal time = 0;
for (var tmp = 0; tmp < num; tmp++) {
using (var P = IsSolveCreated
? new Problem(false, new Scanner("input.txt"),
new Printer())
: new Problem(false)) {
size = P.Size;
// time += Func.MeasureTime(() => P.Solve());
}
}
Console.WriteLine("{0}, {1}ms", size, time / num);
}
}
}
/// <summary>
/// カスタマイズしたIO
/// </summary>
namespace MyIO {
class Printer : IDisposable {
bool isConsole;
TextWriter file;
public Printer() {
file = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
isConsole = true;
}
public Printer(string path) {
file = new StreamWriter(path, false) { AutoFlush = false };
isConsole = false;
}
public void Write<T>(T value) { file.Write(value); }
public void Write(bool b) { file.Write(b ? "YES" : "NO"); }
public void Write(string str, params object[] args) { file.Write(str, args); }
public void WriteLine() { file.WriteLine(); }
public void WriteLine<T>(T value) { file.WriteLine(value); }
public void WriteLine(bool b) { file.WriteLine(b ? "YES" : "NO"); }
public void WriteLine<T>(IEnumerable<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(List<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(T[] list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine(string str, params object[] args) {
file.WriteLine(str, args);
}
public void Dispose() {
file.Flush();
if (!isConsole)
file.Dispose();
}
}
class Scanner : IDisposable {
bool isConsole;
TextReader file;
public Scanner() { file = Console.In; }
public Scanner(string path) {
file = new StreamReader(path);
isConsole = false;
}
public void Dispose() {
if (!isConsole)
file.Dispose();
}
#region next読み込み
string[] nextBuffer = new string[0];
int BufferCnt = 0;
char[] cs = new char[] { ' ' };
public string next() {
while (BufferCnt >= nextBuffer.Length) {
string st = file.ReadLine();
while (st == "")
st = file.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
}
return nextBuffer[BufferCnt++];
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public string[] next(int n) { return enumerate(n, next); }
public double[] nextDouble(int n) { return enumerate(n, nextDouble); }
public int[] nextInt(int n) { return enumerate(n, nextInt); }
public long[] nextLong(int n) { return enumerate(n, nextLong); }
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
// using System.Numerics; //comment out if AOJ
using System.Text;
using Problem = Tmp.Problem;
using MyIO;
#pragma warning disable // for AOJ
namespace Tmp {
class Problem : IDisposable {
bool IsGCJ;
int Repeat;
Scanner sc;
Printer pr;
public Problem(bool isGCJ, Scanner scanner, Printer printer) {
sc = scanner;
pr = printer;
IsGCJ = isGCJ;
if (isGCJ)
Repeat = sc.nextInt();
else
Read();
}
public Problem(bool isGCJ) : this(isGCJ, new Scanner(), new Printer()) {}
public Problem(bool isGCJ, Scanner scanner)
: this(isGCJ, scanner, new Printer()) {}
public Problem(bool isGCJ, Printer printer)
: this(isGCJ, new Scanner(), printer) {}
public void Solve() {
if (IsGCJ)
for (var i = 0; i < Repeat; i++) {
Read();
pr.Write("Case #" + (i + 1) + ": ");
SolveOne();
}
else
SolveOne();
}
public void Dispose() {
sc.Dispose();
pr.Dispose();
}
public int Size {
get { return 1; }
}
public const long Mod = 1000000007;
// 使用する変数をここに書く
// string S;
// int a;
/// <summary>
/// 読み込み処理をここに書く
/// </summary>
void Read() {}
/// <summary>
/// メイン処理をここに書く
/// </summary>
void SolveOne() {
long k = sc.nextLong();
HashSet<long> set = new HashSet<long>();
for (int i = 1; i < 10; i++) {
set.Add(i);
}
long keta = 10;
while (keta < 10e16) {
for (int i = 1; i < 200; i++) {
set.Add(i * keta - 1);
}
keta *= 10;
}
long[] numls = set.ToArray();
double[] scorels = new double[numls.Length];
for (int i = 0; i < numls.Length; i++) {
scorels[i] = SnukeNumCalc(numls[i]);
}
List<long> ans = new List<long>();
double scoreMin = double.MaxValue / 3;
for (int i = numls.Length - 1; i >= 0; i--) {
if (scorels[i] <= scoreMin) {
ans.Add(numls[i]);
scoreMin = scorels[i];
}
}
ans.Reverse();
for (int i = 0; i < k; i++) {
Console.WriteLine(ans[i]);
}
}
long ketaSumCalc(long n) {
long ret = 0;
while (n > 0) {
ret += n % 10;
n /= 10;
}
return ret;
}
double SnukeNumCalc(long n) { return (double)n / ketaSumCalc(n); }
}
}
class Program {
// public static RandomSFMT rand = new RandomSFMT();
public static bool IsJudgeMode = true;
public static bool IsGCJMode = false;
public static bool IsSolveCreated = true;
static void Main() {
if (IsJudgeMode)
if (IsGCJMode)
using (var problem =
new Problem(true, new Scanner("C-large-practice.in.txt"),
new Printer("output.txt"))) problem.Solve();
else
using (var problem = new Problem(false, new Printer())) problem.Solve();
else {
var num = 1;
int size = 0;
decimal time = 0;
for (var tmp = 0; tmp < num; tmp++) {
using (var P = IsSolveCreated
? new Problem(false, new Scanner("input.txt"),
new Printer())
: new Problem(false)) {
size = P.Size;
// time += Func.MeasureTime(() => P.Solve());
}
}
Console.WriteLine("{0}, {1}ms", size, time / num);
}
}
}
/// <summary>
/// カスタマイズしたIO
/// </summary>
namespace MyIO {
class Printer : IDisposable {
bool isConsole;
TextWriter file;
public Printer() {
file = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
isConsole = true;
}
public Printer(string path) {
file = new StreamWriter(path, false) { AutoFlush = false };
isConsole = false;
}
public void Write<T>(T value) { file.Write(value); }
public void Write(bool b) { file.Write(b ? "YES" : "NO"); }
public void Write(string str, params object[] args) { file.Write(str, args); }
public void WriteLine() { file.WriteLine(); }
public void WriteLine<T>(T value) { file.WriteLine(value); }
public void WriteLine(bool b) { file.WriteLine(b ? "YES" : "NO"); }
public void WriteLine<T>(IEnumerable<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(List<T> list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine<T>(T[] list) {
foreach (var x in list)
file.WriteLine(x);
}
public void WriteLine(string str, params object[] args) {
file.WriteLine(str, args);
}
public void Dispose() {
file.Flush();
if (!isConsole)
file.Dispose();
}
}
class Scanner : IDisposable {
bool isConsole;
TextReader file;
public Scanner() { file = Console.In; }
public Scanner(string path) {
file = new StreamReader(path);
isConsole = false;
}
public void Dispose() {
if (!isConsole)
file.Dispose();
}
#region next読み込み
string[] nextBuffer = new string[0];
int BufferCnt = 0;
char[] cs = new char[] { ' ' };
public string next() {
while (BufferCnt >= nextBuffer.Length) {
string st = file.ReadLine();
while (st == "")
st = file.ReadLine();
nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
BufferCnt = 0;
}
return nextBuffer[BufferCnt++];
}
public int nextInt() { return int.Parse(next()); }
public long nextLong() { return long.Parse(next()); }
public double nextDouble() { return double.Parse(next()); }
private T[] enumerate<T>(int n, Func<T> f) {
var a = new T[n];
for (int i = 0; i < n; ++i)
a[i] = f();
return a;
}
public string[] next(int n) { return enumerate(n, next); }
public double[] nextDouble(int n) { return enumerate(n, nextDouble); }
public int[] nextInt(int n) { return enumerate(n, nextInt); }
public long[] nextLong(int n) { return enumerate(n, nextLong); }
#endregion
}
}
|
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 1,465
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int A, B;
var word = Console.ReadLine().Split(' ');
A = int.Parse(word[0]);
B = int.Parse(word[1]);
if (A + B == 16 && A <= 8 && B <= 8)
Console.WriteLine("Yay!");
else
Console.WriteLine(":(");
Console.ReadKey();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int A, B;
var word = Console.ReadLine().Split(' ');
A = int.Parse(word[0]);
B = int.Parse(word[1]);
if (A <= 8 && B <= 8)
Console.WriteLine("Yay!");
else
Console.WriteLine(":(");
Console.ReadKey();
}
}
}
|
[["-", 15, 16, 31, 16, 31, 16, 31, 16, 17, 72], ["-", 15, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 17, 60], ["-", 0, 57, 15, 16, 31, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 98], ["-", 0, 57, 15, 16, 31, 16, 12, 16, 31, 22]]
| 8
| 132
| 6
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(ab.Max() >= 8 ? ":(" : "Yay!");
}
}
}
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
Console.WriteLine(ab.Max() > 8 ? ":(" : "Yay!");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 15, 16, 17, 20], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 47]]
| 8
| 72
| 2
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int a;
int b;
int[] imp =
Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
a = imp[0];
b = imp[0];
string ans;
if (a < 9 && b < 9)
ans = "Yay!";
else
ans = ":(";
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int a;
int b;
int[] imp =
Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
a = imp[0];
b = imp[1];
string ans;
if (a < 9 && b < 9)
ans = "Yay!";
else
ans = ":(";
Console.WriteLine(ans);
}
}
|
[["-", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 11, 12, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 110
| 2
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int A = int.Parse(s[0]);
int B = int.Parse(s[1]);
if (A > 6 || B > 6) {
Console.WriteLine(":(");
} else
Console.WriteLine("Yay!");
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int A = int.Parse(s[0]);
int B = int.Parse(s[1]);
if (A > 8 || B > 8) {
Console.WriteLine(":(");
} else
Console.WriteLine("Yay!");
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 97
| 4
|
using System;
using System.Linq;
public class c {
public static void Main() {
int[] AB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
if (AB[0] > 8 || AB[1] > 8)
Console.WriteLine(":(");
else
Console.WriteLine("Yay");
}
}
|
using System;
using System.Linq;
public class c {
public static void Main() {
int[] AB = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
if (AB[0] > 8 || AB[1] > 8)
Console.WriteLine(":(");
else
Console.WriteLine("Yay!");
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 85
| 2
|
using System;
namespace ABC100_A_Happy_Birthday {
internal class Program {
public static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if (a <= 8 || b <= 8) {
Console.WriteLine("Yay!");
} else {
Console.WriteLine(":(");
}
}
}
}
|
using System;
namespace ABC100_A_Happy_Birthday {
internal class Program {
public static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if (a <= 8 && b <= 8) {
Console.WriteLine("Yay!");
} else {
Console.WriteLine(":(");
}
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 101
| 2
|
using System;
namespace Csharp_Test {
class Program {
static void Main(string[] args) {
string[] temp = Console.ReadLine().Split(' ');
int A = int.Parse(temp[0]);
int B = int.Parse(temp[1]);
string ans = "Yay!";
if (A > 9 || B > 9) {
ans = ":(";
}
Console.WriteLine(ans);
}
}
}
|
using System;
namespace Csharp_Test {
class Program {
static void Main(string[] args) {
string[] temp = Console.ReadLine().Split(' ');
int A = int.Parse(temp[0]);
int B = int.Parse(temp[1]);
string ans = "Yay!";
if (A > 8 || B > 8) {
ans = ":(";
}
Console.WriteLine(ans);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 203], ["-", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 203]]
| 8
| 98
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
var AB = ReadLine().Split().Select(int.Parse).ToArray();
var A = AB[0];
var B = AB[1];
WriteLine(A < 7 && B < 7 ? "Yay!" : ":(");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
var AB = ReadLine().Split().Select(int.Parse).ToArray();
var A = AB[0];
var B = AB[1];
WriteLine(A < 9 && B < 9 ? "Yay!" : ":(");
}
}
|
[["-", 0, 28, 0, 41, 15, 16, 31, 16, 12, 203], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 12, 203], ["-", 0, 28, 0, 41, 15, 16, 12, 16, 12, 203], ["+", 0, 28, 0, 41, 15, 16, 12, 16, 12, 203]]
| 8
| 89
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var p = Console.ReadLine().Split(' ');
long A = long.Parse(p[0]);
long B = long.Parse(p[1]);
if (A <= 8 || B <= 8) {
Console.WriteLine("Yay!");
} else {
Console.WriteLine(":(");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var p = Console.ReadLine().Split(' ');
long A = long.Parse(p[0]);
long B = long.Parse(p[1]);
if (A <= 8 && B <= 8) {
Console.WriteLine("Yay!");
} else {
Console.WriteLine(":(");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 106], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 105
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderTest001 {
class Program {
static void Main(string[] args) { new Program().Calc(); }
void Calc() {
// read
string[] tmpStr = Console.ReadLine().Split(' ');
int a = int.Parse(tmpStr[0]);
int b = int.Parse(tmpStr[0]);
if (a <= 8 && b <= 8) {
Console.WriteLine("Yay!");
} else {
Console.WriteLine(":(");
}
// int[] cake = new int[16];
// for(int i= 0; i < cake.Length; i++)
//{
// cake[i] = 0;
//}
// for(int i = 0; i < cake.Length ; i++)
//{
// cake.
// if(n == 0)
// {
// Console.WriteLine(i);
// break;
// }
// if(n < 6)
// {
// Console.WriteLine(i + n);
// break;
// }
// else
// {
// if(n - x > n - y)
// {
// n = n - y;
// }
// else
// {
// n = n - x;
// }
// }
//}
// Console.WriteLine(x);
}
int getHeight(int n) {
if (n == 1) {
return 1;
} else {
return getHeight(n - 1) + n;
}
}
int getJijou(int n, int i) {
if (i == 0) {
return 1;
} else {
return n * getJijou(n, i - 1);
}
}
int Maxjijou(int n, int z) {
int ret = 1;
int x = 1;
for (int i = 0;; i++) {
x = getJijou(z, i);
if (x > n) {
return ret;
}
ret = x;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtCoderTest001 {
class Program {
static void Main(string[] args) { new Program().Calc(); }
void Calc() {
// read
string[] tmpStr = Console.ReadLine().Split(' ');
int a = int.Parse(tmpStr[0]);
int b = int.Parse(tmpStr[1]);
if (a <= 8 && b <= 8) {
Console.WriteLine("Yay!");
} else {
Console.WriteLine(":(");
}
// int[] cake = new int[16];
// for(int i= 0; i < cake.Length; i++)
//{
// cake[i] = 0;
//}
// for(int i = 0; i < cake.Length ; i++)
//{
// cake.
// if(n == 0)
// {
// Console.WriteLine(i);
// break;
// }
// if(n < 6)
// {
// Console.WriteLine(i + n);
// break;
// }
// else
// {
// if(n - x > n - y)
// {
// n = n - y;
// }
// else
// {
// n = n - x;
// }
// }
//}
// Console.WriteLine(x);
}
int getHeight(int n) {
if (n == 1) {
return 1;
} else {
return getHeight(n - 1) + n;
}
}
int getJijou(int n, int i) {
if (i == 0) {
return 1;
} else {
return n * getJijou(n, i - 1);
}
}
int Maxjijou(int n, int z) {
int ret = 1;
int x = 1;
for (int i = 0;; i++) {
x = getJijou(z, i);
if (x > n) {
return ret;
}
ret = x;
}
}
}
}
|
[["-", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 28, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 297
| 2
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int[] A =
Console.ReadLine().Split(' ').Select(gg => int.Parse(gg)).ToArray();
int D = A[0];
int N = A[1];
int R = Convert.ToInt32(Math.Pow(100, D));
if (N == 100) {
R += 1;
}
if (D == 0) {
Console.WriteLine(N);
return;
}
Console.WriteLine(R * N);
}
}
}
|
using System;
using System.Linq;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
int[] A =
Console.ReadLine().Split(' ').Select(gg => int.Parse(gg)).ToArray();
int D = A[0];
int N = A[1];
int R = Convert.ToInt32(Math.Pow(100, D));
if (N == 100) {
N += 1;
}
if (D == 0) {
Console.WriteLine(N);
return;
}
Console.WriteLine(R * N);
}
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22]]
| 8
| 132
| 2
|
using System;
using System.Text;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int d = sc.NextInt();
int n = sc.NextInt();
long ans = n == 100 ? 101 : 100;
for (int i = 0; i < d; i++) {
ans *= 100;
}
Console.WriteLine(ans);
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Text;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int d = sc.NextInt();
int n = sc.NextInt();
long ans = n == 100 ? 101 : n;
for (int i = 0; i < d; i++) {
ans *= 100;
}
Console.WriteLine(ans);
}
public static void Main(string[] args) => new Program().Solve();
}
namespace CompLib.Util {
using System;
using System.Linq;
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 41, 75, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 41, 75, 22]]
| 8
| 417
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static void Main(string[] args) {
try {
Solve.Answer();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var nd = IO.ReadSplitInt;
var ans = 0;
if (nd[0] == 0) {
ans = nd[1];
if (ans == 100)
ans = 101;
} else if (nd[0] == 1) {
ans = nd[1] * 100;
if (ans == 10000)
ans = 10100;
} else {
ans = nd[1] * 10000;
if (ans == 1)
ans = 1010000;
}
WriteLine(ans);
}
public class IO {
#region Input
public static string ReadString => ReadLine();
public static int ReadInt => int.Parse(ReadLine());
public static long ReadLong => long.Parse(ReadLine());
public static double ReadDouble => double.Parse(ReadLine());
public static List<string> ReadSplitString => ReadLine().Split().ToList();
public static List<int> ReadSplitInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToList();
public static List<long> ReadSplitLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToList();
public static List<double> ReadSplitdouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToList();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
#endregion
}
public class Mod {
#region
// 割る数の定義
private readonly static long M = 1000000007;
// 足し算
public static long Add(long a, long b) => (a * b) % M;
// 引き算
public static long Sub(long a, long b) => (a - b) % M >= 0
? (a - b) % M
: (a - b) % M + M;
// 掛け算
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
public class Scanner {
#region
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
// public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
// public int[] ArrInt1D(int n) => Create(n, () => Int);
// public long[] ArrLong1D(int n) => Create(n, () => Long);
// public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
// public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
// インライン化を推奨する
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
#endregion
}
public static long GCD(long x, long y) {
#region
if (x < y) {
var tmp = x;
x = y;
y = tmp;
}
while (true)
{
if (x % y == 0) {
return y;
} else {
var tmp = x;
x = y;
y = tmp % y;
}
}
#endregion
}
public static long Choice2(long n) {
#region
if (n <= 1)
return 0;
if (n == 2)
return 1;
else
return n * (n - 1) / 2;
#endregion
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;
namespace Atcoder {
class Program {
static void Main(string[] args) {
try {
Solve.Answer();
} catch (Exception ex) {
WriteLine(ex.ToString());
}
}
}
public class Solve {
public static void Answer() {
var nd = IO.ReadSplitInt;
var ans = 0;
if (nd[0] == 0) {
ans = nd[1];
if (ans == 100)
ans = 101;
} else if (nd[0] == 1) {
ans = nd[1] * 100;
if (ans == 10000)
ans = 10100;
} else {
ans = nd[1] * 10000;
if (ans == 1000000)
ans = 1010000;
}
WriteLine(ans);
}
public class IO {
#region Input
public static string ReadString => ReadLine();
public static int ReadInt => int.Parse(ReadLine());
public static long ReadLong => long.Parse(ReadLine());
public static double ReadDouble => double.Parse(ReadLine());
public static List<string> ReadSplitString => ReadLine().Split().ToList();
public static List<int> ReadSplitInt =>
ReadLine().Split().Select(s => int.Parse(s)).ToList();
public static List<long> ReadSplitLong =>
ReadLine().Split().Select(s => long.Parse(s)).ToList();
public static List<double> ReadSplitdouble =>
ReadLine().Split().Select(s => double.Parse(s)).ToList();
#endregion
#region Output
public static void
OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes"
: "No");
#endregion
}
public class Mod {
#region
// 割る数の定義
private readonly static long M = 1000000007;
// 足し算
public static long Add(long a, long b) => (a * b) % M;
// 引き算
public static long Sub(long a, long b) => (a - b) % M >= 0
? (a - b) % M
: (a - b) % M + M;
// 掛け算
public static long Multi(long a, long b) => (a * b) % M;
#endregion
}
public class Scanner {
#region
public string Str => Console.ReadLine().Trim();
public int Int => int.Parse(Str);
public long Long => long.Parse(Str);
public double Double => double.Parse(Str);
public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
// public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
// public int[] ArrInt1D(int n) => Create(n, () => Int);
// public long[] ArrLong1D(int n) => Create(n, () => Long);
// public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
// public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
private Queue<string> q = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
// インライン化を推奨する
public T Next<T>() {
if (q.Count == 0)
foreach (var item in Str.Split(' '))
q.Enqueue(item);
return (T)Convert.ChangeType(q.Dequeue(), typeof(T));
}
public void Make<T1>(out T1 v1) => v1 = Next<T1>();
public void Make<T1, T2>(out T1 v1, out T2 v2) {
v1 = Next<T1>();
v2 = Next<T2>();
}
public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) {
Make(out v1, out v2);
v3 = Next<T3>();
}
public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4) {
Make(out v1, out v2, out v3);
v4 = Next<T4>();
}
public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5) {
Make(out v1, out v2, out v3, out v4);
v5 = Next<T5>();
}
public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3,
out T4 v4, out T5 v5, out T6 v6) {
Make(out v1, out v2, out v3, out v4, out v5);
v6 = Next<T6>();
}
#endregion
}
public static long GCD(long x, long y) {
#region
if (x < y) {
var tmp = x;
x = y;
y = tmp;
}
while (true)
{
if (x % y == 0) {
return y;
} else {
var tmp = x;
x = y;
y = tmp % y;
}
}
#endregion
}
public static long Choice2(long n) {
#region
if (n <= 1)
return 0;
if (n == 2)
return 1;
else
return n * (n - 1) / 2;
#endregion
}
}
}
|
[["-", 75, 57, 75, 196, 0, 57, 15, 16, 12, 203], ["+", 75, 57, 75, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 1,127
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var D = sc.ReadInt();
var N = sc.ReadInt();
var k = (long)Math.Pow(100, D);
var ans = k * N;
if (D == 0 && N == 100) {
ans++;
}
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var D = sc.ReadInt();
var N = sc.ReadInt();
var k = (long)Math.Pow(100, D);
var ans = k * N;
if (N == 100) {
ans += k;
}
Console.WriteLine(ans);
}
static Scanner sc = new Scanner();
}
class Scanner {
string[] S = new string[0];
int Index = 0;
char[] Separators = new char[] { ' ' };
public string Next() {
if (this.Index < this.S.Length)
return this.S[this.Index++];
var line = "";
while (line == "")
line = Console.ReadLine();
this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
if (this.S.Length == 0)
return this.Next();
this.Index = 0;
return this.S[this.Index++];
}
public string ReadStr() { return this.Next(); }
public char ReadChar() { return this.Next()[0]; }
public int ReadInt() { return int.Parse(this.Next()); }
public uint ReadUInt() { return uint.Parse(this.Next()); }
public long ReadLong() { return long.Parse(this.Next()); }
public double ReadDouble() { return double.Parse(this.Next()); }
public Tuple<int, int> ReadTup(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add);
}
public Tuple<long, long> ReadTupLong(int add = 0) {
return Tuple.Create(this.ReadLong() + add, this.ReadLong() + add);
}
public Tuple<int, int, int> ReadTup3(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add);
}
public Tuple<int, int, int, int> ReadTup4(int add = 0) {
return Tuple.Create(this.ReadInt() + add, this.ReadInt() + add,
this.ReadInt() + add, this.ReadInt() + add);
}
public int[] ReadIntArray(int n) {
var array = new int[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadInt();
}
return array;
}
public long[] ReadLongArray(int n) {
var array = new long[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadLong();
}
return array;
}
public double[] ReadDoubleArray(int n) {
var array = new double[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadDouble();
}
return array;
}
public char[] ReadCharArray(int n) {
var array = new char[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadChar();
}
return array;
}
public string[] ReadStrArray(int n) {
var array = new string[n];
for (int i = 0; i < array.Length; i++) {
array[i] = this.ReadStr();
}
return array;
}
public Tuple<long, long>[] ReadTupLongArray(int n, int add = 0) {
var array = new Tuple<long, long>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTupLong(add);
}
return array;
}
public Tuple<int, int>[] ReadTupArray(int n, int add = 0) {
var array = new Tuple<int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup(add);
}
return array;
}
public Tuple<int, int, int>[] ReadTup3Array(int n, int add = 0) {
var array = new Tuple<int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup3(add);
}
return array;
}
public Tuple<int, int, int, int>[] ReadTup4Array(int n, int add = 0) {
var array = new Tuple<int, int, int, int>[n];
for (int i = 0; i < n; i++) {
array[i] = this.ReadTup4(add);
}
return array;
}
}
|
[["-", 8, 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, 203], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["-", 0, 57, 64, 196, 0, 1, 0, 223, 0, 29], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 22]]
| 8
| 1,063
| 7
|
using System;
using System.Collections.Generic;
using System.Linq;
struct input {
public long D;
public long N;
}
class MainClass {
static input input;
public static void Main(string[] args) {
var temp = Console.ReadLine().Split(' ').Select(long.Parse);
input.D = temp.ElementAt(0);
input.N = temp.ElementAt(1);
var ans = Math.Pow(100, input.D) * input.N;
if (input.D == 0 && ans % 100 == 0) {
ans++;
} else if (input.D == 1 && ans % 10000 == 0) {
ans += Math.Pow(100, input.D);
} else if (input.D == 2 && ans % 100 == 0) {
ans += Math.Pow(100, input.D);
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
struct input {
public long D;
public long N;
}
class MainClass {
static input input;
public static void Main(string[] args) {
var temp = Console.ReadLine().Split(' ').Select(long.Parse);
input.D = temp.ElementAt(0);
input.N = temp.ElementAt(1);
var ans = Math.Pow(100, input.D) * input.N;
if (input.D == 0 && ans % 100 == 0) {
ans++;
} else if (input.D == 1 && ans % 10000 == 0) {
ans += Math.Pow(100, input.D);
} else if (input.D == 2 && ans % 1000000 == 0) {
ans += Math.Pow(100, input.D);
}
Console.WriteLine(ans);
}
}
|
[["-", 75, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 75, 57, 15, 16, 12, 16, 31, 16, 12, 203]]
| 8
| 196
| 2
|
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 input = Reads();
var d = input[0];
var n = input[1];
if (d == 0) {
if (n != 100)
Console.WriteLine(n);
else
Console.WriteLine(101);
} else if (d == 1) {
if (n != 100)
Console.WriteLine(n * 100);
else
Console.WriteLine(10100);
} else {
if (n != 100)
Console.WriteLine(n * 10000);
else
Console.WriteLine(1000100);
}
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 input = Reads();
var d = input[0];
var n = input[1];
if (d == 0) {
if (n != 100)
Console.WriteLine(n);
else
Console.WriteLine(101);
} else if (d == 1) {
if (n != 100)
Console.WriteLine(n * 100);
else
Console.WriteLine(10100);
} else {
if (n != 100)
Console.WriteLine(n * 10000);
else
Console.WriteLine(1010000);
}
Console.Out.Flush();
}
}
}
|
[["-", 75, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 75, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 234
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Ha2ne2Util.Cin;
using static Ha2ne2Util.Util;
using static System.Console;
using static System.Math;
using System.Collections;
using Pair = System.Tuple<long, long>;
/// <summary>
/// https://atcoder.jp/contests/abc100
/// 2020/02/03
/// </summary>
namespace ABC100 {
public class Program {
public static void Main(string[] args) {
// A(); 5m
B();
// C();
// D();
}
public static void D() {}
public static void C() {}
public static void B() {
long D = rl;
long N = rl;
if (D == 0 && N == 100) {
Console.WriteLine("101");
return;
}
if (D == 1 && N == 100) {
Console.WriteLine("10001");
return;
}
if (D == 2 && N == 100) {
Console.WriteLine("1000001");
return;
}
D = (long)Math.Pow(100, D) * N;
Console.WriteLine(D);
}
public static void A() {
long A = rl;
long B = rl;
string ans = (Abs(A - B) <= 1) ? "Yay!" : ":(";
Console.WriteLine(ans);
}
}
}
namespace Ha2ne2Util {
public static class Cin {
private static string[] Tokens { get; set; }
private static int Pointer { get; set; }
public static string Next() {
if (Tokens == null || Tokens.Length <= Pointer) {
Tokens = Console.ReadLine().Split(' ');
Pointer = 0;
}
return Tokens[Pointer++];
}
public static int ReadInt() { return int.Parse(Next()); }
public static long rl => ReadLong();
public static long[] rla => ReadLongArray();
public static double rd => ReadDouble();
public static double[] rda => ReadDoubleArray();
public static long ReadLong() { return long.Parse(Next()); }
public static double ReadDouble() { return double.Parse(Next()); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static void ReadArrays(out long[] a, out long[] b, long N) {
a = new long[N];
b = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
}
}
public static void ReadArrays(out long[] a, out long[] b, out long[] c,
long N) {
a = new long[N];
b = new long[N];
c = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
c[i] = ReadLong();
}
}
public static int[][] ReadIntTable(int n) {
Tokens = null;
int[][] ret = new int [n][];
for (int i = 0; i < n; i++) {
ret[i] = ReadIntArray();
}
return ret;
}
public static long[][] ReadLongTable(long n) {
Tokens = null;
long[][] ret = new long [n][];
for (long i = 0; i < n; i++) {
ret[i] = ReadLongArray();
}
return ret;
}
public static string ReadString() { return Next(); }
/// <summary>
/// "00101001010"という様な入力をintの配列にして返す
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().ToArray(),
c => int.Parse(c.ToString()));
}
/// <summary>
/// "00101001010"という様な入力をboolの配列にして返す
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
Tokens = null;
return Console.ReadLine().Select(c => c == '1').ToArray();
}
}
/// <summary>
/// ユーティリティー
/// </summary>
public static class Util {
// 10^17
public static readonly long INF = (long)1e17;
public static IEnumerable<int> Range(int end) {
for (int i = 0; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end) {
for (int i = from; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end, int step) {
for (int i = from; i < end; i += step) {
yield return i;
}
}
/// <summary>
/// ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// 降順ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] SortDecend<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyにあるようなやつ
/// ex) 5.Times(i => Console.WriteLine(i));
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
/// <summary>
/// 引数aと引数bの値を入れ替えます
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
/// <summary>
/// Console.WriteLineの自動フラッシュをしないようにする
/// </summary>
public static void DontAutoFlush() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
/// <summary>
/// 先頭と末尾に要素を増やした新しい配列を返します。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] AddHeadAndTail<T>(T[] array) {
int len = array.Length;
T[] res = new T[len + 2];
Array.Copy(array, 0, res, 1, len);
return res;
}
/// <summary>
/// 昇順ソート済みの配列を2分探索します。
/// 要素が見つからなかった場合はnより大きい数値の中で最小の数値のインデックスを返す。
/// </summary>
/// <param name="array"></param>
/// <param name="n"></param>
/// <returns></returns>
public static int BinarySearch(long[] array, long n) {
int left = 0;
int right = array.Length - 1;
while (left <= right) {
int mid = (right - left) / 2 + left;
if (array[mid] == n) {
return mid;
} else if (n < array[mid]) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return left;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static int[] GetDivisor(int n) {
double sqrt = Math.Sqrt(n);
List<int> divisor = new List<int>();
for (int i = 1; i <= sqrt; i++) {
if (n % i == 0) {
divisor.Add(i);
int tmp = n / i;
if (tmp != i) {
divisor.Add(tmp);
}
}
}
return Sort(divisor.ToArray());
}
public static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
public static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
public static void Deconstruct<T>(this T[] items, out T t0) {
t0 = items.Length > 0 ? items[0] : default(T);
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1) {
if (items.Length < 2)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2) {
if (items.Length < 3)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2, out T t3) {
if (items.Length < 4)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
t3 = items[3];
}
public static void ArrayInitialize<T>(T[,] array, T value) {
int len0 = array.GetLength(0);
int len1 = array.GetLength(1);
for (int i = 0; i < len0; i++) {
for (int j = 0; j < len1; j++) {
array[i, j] = value;
}
}
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public readonly static int MOD = 1000000007;
public static long ModAdd(long a, long b) {
long res = a + b;
if (res >= MOD)
return res % MOD;
return res;
}
public static long ModMul(long a, long b) {
long res = a * b;
if (res >= MOD)
return res % MOD;
return res;
}
public static void ModAddEqual(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long minValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (n < minValue) {
min = x;
}
}
return min;
}
public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long maxValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (maxValue < n) {
min = x;
}
}
return min;
}
public static void FillArray<T>(T[] array, T value) {
int max = array.Length;
for (int i = 0; i < max; i++) {
array[i] = value;
}
}
public static void FillArray<T>(T[,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
array[i, j] = value;
}
}
}
public static void FillArray<T>(T[,,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
int max2 = array.GetLength(2);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
for (int k = 0; k < max2; k++) {
array[i, j, k] = value;
}
}
}
}
}
/// <summary>
/// HashSetにTupleを入れた時の、等値性判定方法の指定に使います。
/// HashSetのコンストラクタに渡して使います。
/// EqualsとGetHashCodeを提供します。
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// UnionFindTree
/// </summary>
public class UnionFindTree {
public int[] Node;
public UnionFindTree(int N) {
Node = new int[N];
for (int i = 0; i < N; i++) {
Node[i] = -1;
}
}
public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); }
public bool Merge(int x, int y) {
int xr = GetRoot(x);
int yr = GetRoot(y);
if (xr == yr)
return false;
// xが、大きなグループを示すようにSwapする(値が小さい方が大きなグループ)
if (Node[xr] > Node[yr])
Swap(ref xr, ref yr);
// グループの数を合算する
Node[xr] += Node[yr];
// 根を張り替える
Node[yr] = xr;
return true;
}
public int Size(int x) { return -Node[GetRoot(x)]; }
public int GetRoot(int n) {
if (Node[n] < 0) {
return n;
} else {
// 根を張りなおす。
Node[n] = GetRoot(Node[n]);
return Node[n];
}
}
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T> {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
return _comparison(x, y);
// if (_comparison != null) return _comparison(x, y);
// return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Ha2ne2Util.Cin;
using static Ha2ne2Util.Util;
using static System.Console;
using static System.Math;
using System.Collections;
using Pair = System.Tuple<long, long>;
/// <summary>
/// https://atcoder.jp/contests/abc100
/// 2020/02/03
/// </summary>
namespace ABC100 {
public class Program {
public static void Main(string[] args) {
// A(); 5m
B();
// C();
// D();
}
public static void D() {}
public static void C() {}
public static void B() {
long D = rl;
long N = rl;
if (D == 0 && N == 100) {
Console.WriteLine("101");
return;
}
if (D == 1 && N == 100) {
Console.WriteLine("10100");
return;
}
if (D == 2 && N == 100) {
Console.WriteLine("1010000");
return;
}
D = (long)Math.Pow(100, D) * N;
Console.WriteLine(D);
}
public static void A() {
long A = rl;
long B = rl;
string ans = (Abs(A - B) <= 1) ? "Yay!" : ":(";
Console.WriteLine(ans);
}
}
}
namespace Ha2ne2Util {
public static class Cin {
private static string[] Tokens { get; set; }
private static int Pointer { get; set; }
public static string Next() {
if (Tokens == null || Tokens.Length <= Pointer) {
Tokens = Console.ReadLine().Split(' ');
Pointer = 0;
}
return Tokens[Pointer++];
}
public static int ReadInt() { return int.Parse(Next()); }
public static long rl => ReadLong();
public static long[] rla => ReadLongArray();
public static double rd => ReadDouble();
public static double[] rda => ReadDoubleArray();
public static long ReadLong() { return long.Parse(Next()); }
public static double ReadDouble() { return double.Parse(Next()); }
public static int[] ReadIntArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
public static long[] ReadLongArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
public static double[] ReadDoubleArray() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
}
public static void ReadArrays(out long[] a, out long[] b, long N) {
a = new long[N];
b = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
}
}
public static void ReadArrays(out long[] a, out long[] b, out long[] c,
long N) {
a = new long[N];
b = new long[N];
c = new long[N];
for (int i = 0; i < N; i++) {
a[i] = ReadLong();
b[i] = ReadLong();
c[i] = ReadLong();
}
}
public static int[][] ReadIntTable(int n) {
Tokens = null;
int[][] ret = new int [n][];
for (int i = 0; i < n; i++) {
ret[i] = ReadIntArray();
}
return ret;
}
public static long[][] ReadLongTable(long n) {
Tokens = null;
long[][] ret = new long [n][];
for (long i = 0; i < n; i++) {
ret[i] = ReadLongArray();
}
return ret;
}
public static string ReadString() { return Next(); }
/// <summary>
/// "00101001010"という様な入力をintの配列にして返す
/// </summary>
/// <returns></returns>
public static int[] ReadIntArrayFromBinaryString() {
Tokens = null;
return Array.ConvertAll(Console.ReadLine().ToArray(),
c => int.Parse(c.ToString()));
}
/// <summary>
/// "00101001010"という様な入力をboolの配列にして返す
/// </summary>
/// <returns></returns>
public static bool[] ReadBoolArrayFromBinaryString() {
Tokens = null;
return Console.ReadLine().Select(c => c == '1').ToArray();
}
}
/// <summary>
/// ユーティリティー
/// </summary>
public static class Util {
// 10^17
public static readonly long INF = (long)1e17;
public static IEnumerable<int> Range(int end) {
for (int i = 0; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end) {
for (int i = from; i < end; i++) {
yield return i;
}
}
public static IEnumerable<int> Range(int from, int end, int step) {
for (int i = from; i < end; i += step) {
yield return i;
}
}
/// <summary>
/// ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] Sort<T>(T[] array) {
Array.Sort<T>(array);
return array;
}
/// <summary>
/// 降順ソートをして結果を返します。
/// 破壊的関数です。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] SortDecend<T>(T[] array) {
Array.Sort<T>(array);
Array.Reverse(array);
return array;
}
/// <summary>
/// Rubyにあるようなやつ
/// ex) 5.Times(i => Console.WriteLine(i));
/// </summary>
/// <param name="times"></param>
/// <param name="action"></param>
public static void Times(this int times, Action<int> action) {
for (int i = 0; i < times; i++) {
action(i);
}
}
/// <summary>
/// 引数aと引数bの値を入れ替えます
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
public static void Swap<T>(ref T a, ref T b) {
T _a = a;
a = b;
b = _a;
}
/// <summary>
/// Console.WriteLineの自動フラッシュをしないようにする
/// </summary>
public static void DontAutoFlush() {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
public static void Flush() { Console.Out.Flush(); }
/// <summary>
/// 先頭と末尾に要素を増やした新しい配列を返します。
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="array"></param>
/// <returns></returns>
public static T[] AddHeadAndTail<T>(T[] array) {
int len = array.Length;
T[] res = new T[len + 2];
Array.Copy(array, 0, res, 1, len);
return res;
}
/// <summary>
/// 昇順ソート済みの配列を2分探索します。
/// 要素が見つからなかった場合はnより大きい数値の中で最小の数値のインデックスを返す。
/// </summary>
/// <param name="array"></param>
/// <param name="n"></param>
/// <returns></returns>
public static int BinarySearch(long[] array, long n) {
int left = 0;
int right = array.Length - 1;
while (left <= right) {
int mid = (right - left) / 2 + left;
if (array[mid] == n) {
return mid;
} else if (n < array[mid]) {
right = mid - 1;
} else {
left = mid + 1;
}
}
return left;
}
public static int GCD(int a, int b) { return (b == 0) ? a : GCD(b, a % b); }
public static int[] GetDivisor(int n) {
double sqrt = Math.Sqrt(n);
List<int> divisor = new List<int>();
for (int i = 1; i <= sqrt; i++) {
if (n % i == 0) {
divisor.Add(i);
int tmp = n / i;
if (tmp != i) {
divisor.Add(tmp);
}
}
}
return Sort(divisor.ToArray());
}
public static int[] LongToBinaryArray(long n) {
List<int> lst = new List<int>();
while (n > 0) {
int amari = (int)(n % 2);
lst.Add(amari);
n /= 2;
}
return lst.ToArray();
}
public static long BinaryArrayToLong(int[] binaryArray) {
long result = 0;
long b = 1;
int len = binaryArray.Length;
for (int i = 0; i < len; i++) {
result += binaryArray[i] * b;
b *= 2;
}
return result;
}
public static void Deconstruct<T>(this T[] items, out T t0) {
t0 = items.Length > 0 ? items[0] : default(T);
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1) {
if (items.Length < 2)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2) {
if (items.Length < 3)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
}
public static void Deconstruct<T>(this T[] items, out T t0, out T t1,
out T t2, out T t3) {
if (items.Length < 4)
throw new ArgumentException();
t0 = items[0];
t1 = items[1];
t2 = items[2];
t3 = items[3];
}
public static void ArrayInitialize<T>(T[,] array, T value) {
int len0 = array.GetLength(0);
int len1 = array.GetLength(1);
for (int i = 0; i < len0; i++) {
for (int j = 0; j < len1; j++) {
array[i, j] = value;
}
}
}
public static void ChMax(ref long a, long b) {
if (a < b)
a = b;
}
public static void ChMin(ref long a, long b) {
if (a > b)
a = b;
}
public readonly static int MOD = 1000000007;
public static long ModAdd(long a, long b) {
long res = a + b;
if (res >= MOD)
return res % MOD;
return res;
}
public static long ModMul(long a, long b) {
long res = a * b;
if (res >= MOD)
return res % MOD;
return res;
}
public static void ModAddEqual(ref long a, long b) {
a += b;
if (a >= MOD)
a %= MOD;
}
public static T MinBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long minValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (n < minValue) {
min = x;
}
}
return min;
}
public static T MaxBy<T>(this IEnumerable<T> source, Func<T, long> conv) {
T min = source.First();
long maxValue = conv(min);
foreach (T x in source.Skip(1)) {
long n = conv(x);
if (maxValue < n) {
min = x;
}
}
return min;
}
public static void FillArray<T>(T[] array, T value) {
int max = array.Length;
for (int i = 0; i < max; i++) {
array[i] = value;
}
}
public static void FillArray<T>(T[,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
array[i, j] = value;
}
}
}
public static void FillArray<T>(T[,,] array, T value) {
int max0 = array.GetLength(0);
int max1 = array.GetLength(1);
int max2 = array.GetLength(2);
for (int i = 0; i < max0; i++) {
for (int j = 0; j < max1; j++) {
for (int k = 0; k < max2; k++) {
array[i, j, k] = value;
}
}
}
}
}
/// <summary>
/// HashSetにTupleを入れた時の、等値性判定方法の指定に使います。
/// HashSetのコンストラクタに渡して使います。
/// EqualsとGetHashCodeを提供します。
/// </summary>
/// <typeparam name="T"></typeparam>
public class EqualityComparer<T> : IEqualityComparer<T> {
private Func<T, T, bool> _equals;
private Func<T, int> _getHashCode;
public EqualityComparer(Func<T, T, bool> equals, Func<T, int> getHashCode) {
_equals = equals;
_getHashCode = getHashCode;
}
public bool Equals(T x, T y) { return _equals(x, y); }
public int GetHashCode(T obj) { return _getHashCode(obj); }
}
/// <summary>
/// UnionFindTree
/// </summary>
public class UnionFindTree {
public int[] Node;
public UnionFindTree(int N) {
Node = new int[N];
for (int i = 0; i < N; i++) {
Node[i] = -1;
}
}
public bool IsSameGroup(int x, int y) { return GetRoot(x) == GetRoot(y); }
public bool Merge(int x, int y) {
int xr = GetRoot(x);
int yr = GetRoot(y);
if (xr == yr)
return false;
// xが、大きなグループを示すようにSwapする(値が小さい方が大きなグループ)
if (Node[xr] > Node[yr])
Swap(ref xr, ref yr);
// グループの数を合算する
Node[xr] += Node[yr];
// 根を張り替える
Node[yr] = xr;
return true;
}
public int Size(int x) { return -Node[GetRoot(x)]; }
public int GetRoot(int n) {
if (Node[n] < 0) {
return n;
} else {
// 根を張りなおす。
Node[n] = GetRoot(Node[n]);
return Node[n];
}
}
}
/// <summary>
/// PriorityQueue
/// </summary>
/// <typeparam name="T"></typeparam>
public class PriorityQueue<T> {
private Comparison<T> _comparison = null;
private int _type = 0;
private T[] _heap;
private int _sz = 0;
private int _count = 0;
/// <summary>
/// Priority queue
/// </summary>
/// <param name="maxSize">max size</param>
/// <param name="type">0: asc, 1:desc</param>
public PriorityQueue(int maxSize, int type = 0) {
_heap = new T[maxSize];
_type = type;
}
public PriorityQueue(int maxSize, Comparison<T> comparison) {
_heap = new T[maxSize];
_comparison = comparison;
}
private int Compare(T x, T y) {
return _comparison(x, y);
// if (_comparison != null) return _comparison(x, y);
// return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
}
public void Push(T x) {
_count++;
// node number
var i = _sz++;
while (i > 0) {
// parent node number
var p = (i - 1) / 2;
if (Compare(_heap[p], x) <= 0)
break;
_heap[i] = _heap[p];
i = p;
}
_heap[i] = x;
}
public T Pop() {
_count--;
T ret = _heap[0];
T x = _heap[--_sz];
int i = 0;
while (i * 2 + 1 < _sz) {
// children
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < _sz && Compare(_heap[b], _heap[a]) < 0)
a = b;
if (Compare(_heap[a], x) >= 0)
break;
_heap[i] = _heap[a];
i = a;
}
_heap[i] = x;
return ret;
}
public int Count() { return _count; }
public T Peek() { return _heap[0]; }
public bool Contains(T x) {
for (int i = 0; i < _sz; i++)
if (x.Equals(_heap[i]))
return true;
return false;
}
public void Clear() {
while (this.Count() > 0)
this.Pop();
}
public IEnumerator<T> GetEnumerator() {
var ret = new List<T>();
while (this.Count() > 0) {
ret.Add(this.Pop());
}
foreach (var r in ret) {
this.Push(r);
yield return r;
}
}
public T[] ToArray() {
T[] array = new T[_sz];
int i = 0;
foreach (var r in this) {
array[i++] = r;
}
return array;
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 3,420
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp63 {
class Program {
static void Main(string[] args) {
var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
int D = st[0];
int N = st[1];
if (N % 100 != 0) {
Console.WriteLine(Math.Pow(100, D) * N);
} else {
Console.WriteLine(Math.Pow(100, D) * N + 1);
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp63 {
class Program {
static void Main(string[] args) {
var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
int D = st[0];
int N = st[1];
if (N % 100 != 0) {
Console.WriteLine(Math.Pow(100, D) * N);
} else {
Console.WriteLine(Math.Pow(100, D) * (N + 1));
}
}
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 133
| 2
|
using System;
using System.Linq;
namespace ABC {
using System.Collections.Generic;
#if USE_STUB
using static Stub.Console;
#else
using static System.Console;
#endif
using static System.Math;
public class Program {
static void Main(string[] args) {
var DN = ReadLine().Split().Select(int.Parse).ToArray();
var D = DN[0];
var N = DN[1];
var a = Math.Pow(100, D);
WriteLine(a * N + N / 100);
}
}
}
|
using System;
using System.Linq;
namespace ABC {
using System.Collections.Generic;
#if USE_STUB
using static Stub.Console;
#else
using static System.Console;
#endif
using static System.Math;
public class Program {
static void Main(string[] args) {
var DN = ReadLine().Split().Select(int.Parse).ToArray();
var D = DN[0];
var N = DN[1];
var a = Math.Pow(100, D);
WriteLine(a * (N + N / 100));
}
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 121
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class P {
static void Main() {
int d = ReadInt();
int n = ReadInt();
if (n != 100)
Write(n);
else
Write(101);
for (int i = 0; i < d; i++)
Write(0);
WriteLine();
}
//以下標準出入力用のメソッド
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern int scanf(string format, out long l);
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern int scanf(string format, out double l);
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern int scanf(string format, out char c);
public static long ReadLong() {
long l;
scanf("%ld", out l);
return l;
}
public static int ReadInt() { return (int)ReadLong(); }
public static int[] ReadInts(int n) {
int[] nums = new int[n];
for (int i = 0; i < n; i++)
nums[i] = ReadInt();
return nums;
}
public static long[] ReadLongs(int n) {
long[] nums = new long[n];
for (int i = 0; i < n; i++)
nums[i] = ReadLong();
return nums;
}
public static string[] ReadStrs(int n) {
string[] s = new string[n];
for (int i = 0; i < n; i++)
s[i] = ReadStr();
return s;
}
public static double ReadDouble() {
double d;
scanf("%lf", out d);
return d;
}
public static char ReadChar() {
char c;
while (true) {
scanf("%c", out c);
if (c != '\n' && c != ' ')
break;
}
return c;
}
public static string ReadStr() {
StringBuilder sb = new StringBuilder();
char c;
do {
scanf("%c", out c);
} while (c == '\n' || c == ' ');
sb.Append(c);
while (true) {
scanf("%c", out c);
if (c == '\n' || c == ' ')
break;
sb.Append(c);
}
return sb.ToString();
}
public static string ReadLine() {
StringBuilder sb = new StringBuilder();
char c;
do {
scanf("%c", out c);
if (c != '\n')
sb.Append(c);
} while (c != '\n');
return sb.ToString();
}
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern void printf(string s);
public static void Write(string s) { printf(s); }
public static void Write(char c) { printf(c.ToString()); }
public static void Write(long n) { printf(n.ToString()); }
public static void Write(int n) { printf(n.ToString()); }
public static void Write(double d) { printf(d.ToString()); }
public static void WriteLine() { printf("\n"); }
public static void WriteLine(string s) { printf(s + "\n"); }
public static void WriteLine(char c) { WriteLine(c.ToString()); }
public static void WriteLine(long n) { WriteLine(n.ToString()); }
public static void WriteLine(int n) { WriteLine(n.ToString()); }
public static void WriteLine(double d) { WriteLine(d.ToString()); }
public static void WriteLine(string[] s) {
for (int i = 0; i < s.Length - 1; i++)
Write(s[i] + " ");
WriteLine(s[s.Length - 1]);
}
public static void WriteLine(char[] c) {
for (int i = 0; i < c.Length - 1; i++)
Write(c[i] + " ");
WriteLine(c[c.Length - 1]);
}
public static void WriteLine(long[] n) {
for (int i = 0; i < n.Length - 1; i++)
Write(n[i] + " ");
WriteLine(n[n.Length - 1]);
}
public static void WriteLine<T>(ICollection<T> ic) {
foreach (var i in ic)
Write(i + " ");
WriteLine("\b");
}
public static void WriteLine(int[] n) {
for (int i = 0; i < n.Length - 1; i++)
Write(n[i] + " ");
WriteLine(n[n.Length - 1]);
}
public static void WriteLine(double[] d) {
for (int i = 0; i < d.Length - 1; i++)
Write(d[i] + " ");
WriteLine(d[d.Length - 1]);
}
public static void WriteLines(string[] s) {
foreach (var i in s)
WriteLine(i);
}
public static void WriteLines(char[] c) {
foreach (var i in c)
WriteLine(i);
}
public static void WriteLines(long[] c) {
foreach (var i in c)
WriteLine(i);
}
public static void WriteLines(int[] c) {
foreach (var i in c)
WriteLine(i);
}
public static void WriteLines(double[] d) {
foreach (var i in d)
WriteLine(i);
}
public static void WriteLines<T>(ICollection<T> ic) {
WriteLines(ic.ToArray());
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class P {
static void Main() {
int d = ReadInt();
int n = ReadInt();
if (n != 100)
Write(n);
else
Write(101);
for (int i = 0; i < 2 * d; i++)
Write(0);
WriteLine();
}
//以下標準出入力用のメソッド
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern int scanf(string format, out long l);
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern int scanf(string format, out double l);
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern int scanf(string format, out char c);
public static long ReadLong() {
long l;
scanf("%ld", out l);
return l;
}
public static int ReadInt() { return (int)ReadLong(); }
public static int[] ReadInts(int n) {
int[] nums = new int[n];
for (int i = 0; i < n; i++)
nums[i] = ReadInt();
return nums;
}
public static long[] ReadLongs(int n) {
long[] nums = new long[n];
for (int i = 0; i < n; i++)
nums[i] = ReadLong();
return nums;
}
public static string[] ReadStrs(int n) {
string[] s = new string[n];
for (int i = 0; i < n; i++)
s[i] = ReadStr();
return s;
}
public static double ReadDouble() {
double d;
scanf("%lf", out d);
return d;
}
public static char ReadChar() {
char c;
while (true) {
scanf("%c", out c);
if (c != '\n' && c != ' ')
break;
}
return c;
}
public static string ReadStr() {
StringBuilder sb = new StringBuilder();
char c;
do {
scanf("%c", out c);
} while (c == '\n' || c == ' ');
sb.Append(c);
while (true) {
scanf("%c", out c);
if (c == '\n' || c == ' ')
break;
sb.Append(c);
}
return sb.ToString();
}
public static string ReadLine() {
StringBuilder sb = new StringBuilder();
char c;
do {
scanf("%c", out c);
if (c != '\n')
sb.Append(c);
} while (c != '\n');
return sb.ToString();
}
[System.Runtime.InteropServices.DllImport("msvcrt.dll")]
private static extern void printf(string s);
public static void Write(string s) { printf(s); }
public static void Write(char c) { printf(c.ToString()); }
public static void Write(long n) { printf(n.ToString()); }
public static void Write(int n) { printf(n.ToString()); }
public static void Write(double d) { printf(d.ToString()); }
public static void WriteLine() { printf("\n"); }
public static void WriteLine(string s) { printf(s + "\n"); }
public static void WriteLine(char c) { WriteLine(c.ToString()); }
public static void WriteLine(long n) { WriteLine(n.ToString()); }
public static void WriteLine(int n) { WriteLine(n.ToString()); }
public static void WriteLine(double d) { WriteLine(d.ToString()); }
public static void WriteLine(string[] s) {
for (int i = 0; i < s.Length - 1; i++)
Write(s[i] + " ");
WriteLine(s[s.Length - 1]);
}
public static void WriteLine(char[] c) {
for (int i = 0; i < c.Length - 1; i++)
Write(c[i] + " ");
WriteLine(c[c.Length - 1]);
}
public static void WriteLine(long[] n) {
for (int i = 0; i < n.Length - 1; i++)
Write(n[i] + " ");
WriteLine(n[n.Length - 1]);
}
public static void WriteLine<T>(ICollection<T> ic) {
foreach (var i in ic)
Write(i + " ");
WriteLine("\b");
}
public static void WriteLine(int[] n) {
for (int i = 0; i < n.Length - 1; i++)
Write(n[i] + " ");
WriteLine(n[n.Length - 1]);
}
public static void WriteLine(double[] d) {
for (int i = 0; i < d.Length - 1; i++)
Write(d[i] + " ");
WriteLine(d[d.Length - 1]);
}
public static void WriteLines(string[] s) {
foreach (var i in s)
WriteLine(i);
}
public static void WriteLines(char[] c) {
foreach (var i in c)
WriteLine(i);
}
public static void WriteLines(long[] c) {
foreach (var i in c)
WriteLine(i);
}
public static void WriteLines(int[] c) {
foreach (var i in c)
WriteLine(i);
}
public static void WriteLines(double[] d) {
foreach (var i in d)
WriteLine(i);
}
public static void WriteLines<T>(ICollection<T> ic) {
WriteLines(ic.ToArray());
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 31, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 48]]
| 8
| 1,269
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderBeginnerContest100 {
class QB {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
long D = long.Parse(s[0]);
long N = long.Parse(s[1]);
long a = (long)Math.Pow(100, D) * N;
if (D == 0 && N == 100)
Console.WriteLine("101"); //?
else if (D == 1 && N == 100)
Console.WriteLine("10001"); //?
else if (D == 2 && N == 100)
Console.WriteLine("1000001"); //?
else
Console.WriteLine(a);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoderBeginnerContest100 {
class QB {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
long D = long.Parse(s[0]);
long N = long.Parse(s[1]);
long a = (long)Math.Pow(100, D) * N;
if (D == 0 && N == 100)
Console.WriteLine("101"); //?
else if (D == 1 && N == 100)
Console.WriteLine("10100"); //?
else if (D == 2 && N == 100)
Console.WriteLine("1010000"); //?
else
Console.WriteLine(a);
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 165
| 4
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int d = int.Parse(input[0]);
int N = int.Parse(input[1]);
if (N == 100)
N = 99;
Console.WriteLine(Math.Pow(100, d) * N);
// 文字列の入力
// string s = Console.ReadLine();
//出力
// Console.WriteLine((a + b + c) + " " + s);
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
/*string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if (a <= 7 && b <= 7 && a >= 1 && b >= 1)
{
Console.WriteLine("Yay!");
}
else
{
Console.WriteLine(":(");
}*/
// 文字列の入力
// string s = Console.ReadLine();
//出力
// Console.WriteLine((a + b + c) + " " + s);
}
}
}
|
using System;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int d = int.Parse(input[0]);
int N = int.Parse(input[1]);
if (N == 100)
N = 101;
Console.WriteLine(Math.Pow(100, d) * N);
// 文字列の入力
// string s = Console.ReadLine();
//出力
// Console.WriteLine((a + b + c) + " " + s);
// int a = int.Parse(Console.ReadLine());
// スペース区切りの整数の入力
/*string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
int b = int.Parse(input[1]);
if (a <= 7 && b <= 7 && a >= 1 && b >= 1)
{
Console.WriteLine("Yay!");
}
else
{
Console.WriteLine(":(");
}*/
// 文字列の入力
// string s = Console.ReadLine();
//出力
// Console.WriteLine((a + b + c) + " " + s);
}
}
}
|
[["-", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 12, 203]]
| 8
| 103
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
internal static void Main(string[] args) {
int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
if (inp[1] == 100) {
switch (inp[0]) {
case 0:
WriteLine(101);
return;
case 1:
WriteLine(10100);
return;
case 2:
WriteLine(1000100);
return;
}
}
WriteLine((Math.Pow(100, inp[0]) * inp[1]));
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class Program {
internal static void Main(string[] args) {
int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
if (inp[1] == 100) {
switch (inp[0]) {
case 0:
WriteLine(101);
return;
case 1:
WriteLine(10100);
return;
case 2:
WriteLine(1010000);
return;
}
}
WriteLine((Math.Pow(100, inp[0]) * inp[1]));
}
}
|
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 141
| 2
|
using System;
class MainClass {
static void Main() {
string[] s = Console.ReadLine().Split(' ');
int d = int.Parse(s[0]);
int n = int.Parse(s[1]);
if (n != 100)
Console.WriteLine(n * Math.Pow(100, d));
else
Console.WriteLine(n * Math.Pow(101, d));
}
}
|
using System;
class MainClass {
static void Main() {
string[] s = Console.ReadLine().Split(' ');
int d = int.Parse(s[0]);
int n = int.Parse(s[1]);
if (n != 100)
Console.WriteLine(n * Math.Pow(100, d));
else
Console.WriteLine((n + 1) * Math.Pow(100, d));
}
}
|
[["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 24], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 28, 0, 16, 31, 23, 0, 16, 12, 203], ["+", 3, 4, 0, 28, 0, 16, 31, 23, 0, 25], ["-", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 16, 12, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 97
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int D = int.Parse(s[0]);
int N = int.Parse(s[1]);
int ans;
if (D == 0) {
ans = N;
if (ans == 100) {
ans += 1;
}
} else if (D == 1) {
ans = N * 100;
if (ans == 100 * 100) {
ans += 100;
}
} else {
ans = N * 100 * 100;
if (ans == 100 * 100 * 100) {
ans += 100;
}
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int D = int.Parse(s[0]);
int N = int.Parse(s[1]);
int ans;
if (D == 0) {
ans = N;
if (ans == 100) {
ans += 1;
}
} else if (D == 1) {
ans = N * 100;
if (ans == 100 * 100) {
ans += 100;
}
} else {
ans = N * 100 * 100;
if (ans == 100 * 100 * 100) {
ans += 10000;
}
}
Console.WriteLine(ans);
Console.ReadLine();
}
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 203]]
| 8
| 179
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
static void Main(string[] args) {
int[] V = ReadInts();
int D = V[0];
int N = (V[1] == 100) ? V[1] : 101;
Console.WriteLine(new int[] { 1, 100, 10000 }[D] * N);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AtCoder {
class Program {
private static string Read() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(Read()); }
private static long ReadLong() { return long.Parse(Read()); }
private static double ReadDouble() { return double.Parse(Read()); }
private static int[] ReadInts() {
return Array.ConvertAll(Read().Split(), int.Parse);
}
private static long[] ReadLongs() {
return Array.ConvertAll(Read().Split(), long.Parse);
}
private static double[] ReadDoubles() {
return Array.ConvertAll(Read().Split(), double.Parse);
}
static void Main(string[] args) {
int[] V = ReadInts();
int D = V[0];
int N = (V[1] != 100) ? V[1] : 101;
Console.WriteLine(new int[] { 1, 100, 10000 }[D] * N);
}
}
}
|
[["-", 0, 212, 0, 41, 15, 23, 0, 16, 17, 60], ["+", 0, 212, 0, 41, 15, 23, 0, 16, 17, 79]]
| 8
| 250
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass {
public static void Main() {
var str = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var d = str[0];
var n = str[1];
if (d == 0) {
if (n != 100)
Console.WriteLine(n);
else {
Console.WriteLine(101);
}
} else if (d == 1) {
if (n != 100)
Console.WriteLine(n * 100);
else {
Console.WriteLine(10100);
}
} else {
if (n != 100)
Console.WriteLine(n * 10000);
else {
Console.WriteLine(10010000);
}
}
Console.ReadLine();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class MainClass {
public static void Main() {
var str = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var d = str[0];
var n = str[1];
if (d == 0) {
if (n != 100)
Console.WriteLine(n);
else {
Console.WriteLine(101);
}
} else if (d == 1) {
if (n != 100)
Console.WriteLine(n * 100);
else {
Console.WriteLine(10100);
}
} else {
if (n != 100)
Console.WriteLine(n * 10000);
else {
Console.WriteLine(1010000);
}
}
Console.ReadLine();
}
}
|
[["-", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 1, 0, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 174
| 2
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int D = int.Parse(str[0]);
int N = int.Parse(str[1]);
int ans = N;
if (N == 100) {
N += 1;
}
if (D == 1) {
ans *= 100;
} else if (D == 2) {
ans *= 10000;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
int D = int.Parse(str[0]);
int N = int.Parse(str[1]);
int ans = N;
if (N == 100) {
ans += 1;
}
if (D == 1) {
ans *= 100;
} else if (D == 2) {
ans *= 10000;
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22]]
| 8
| 115
| 2
|
using System;
using System.Linq;
namespace abc100_b {
class Program {
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = (int)Math.Pow(10, x[0]);
Console.WriteLine(x[1] == 100 ? n * (x[1] + 1) : n * x[1]);
}
}
}
|
using System;
using System.Linq;
namespace abc100_b {
class Program {
static void Main(string[] args) {
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
int n = (int)Math.Pow(100, x[0]);
Console.WriteLine(x[1] == 100 ? n * (x[1] + 1) : n * x[1]);
}
}
}
|
[["-", 0, 74, 51, 213, 3, 4, 0, 28, 0, 203], ["+", 0, 74, 51, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 101
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
var DN = ReadLine().Split().Select(int.Parse).ToArray();
var D = DN[0];
var N = DN[1];
if (D == 0 && N != 100)
WriteLine(N);
else if (D == 0 && N == 100)
WriteLine(101);
else if (D == 1 && N != 100)
WriteLine(D * N * 100);
else if (D == 1 && N != 100)
WriteLine(10100);
else if (N != 100)
WriteLine(N * 10000);
else
WriteLine(1010000);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Program {
static void Main() {
var DN = ReadLine().Split().Select(int.Parse).ToArray();
var D = DN[0];
var N = DN[1];
if (D == 0 && N != 100)
WriteLine(N);
else if (D == 0 && N == 100)
WriteLine(101);
else if (D == 1 && N != 100)
WriteLine(D * N * 100);
else if (D == 1 && N == 100)
WriteLine(10100);
else if (N != 100)
WriteLine(N * 10000);
else
WriteLine(1010000);
}
}
|
[["-", 75, 57, 75, 57, 15, 16, 12, 16, 17, 79], ["+", 75, 57, 75, 57, 15, 16, 12, 16, 17, 60]]
| 8
| 157
| 2
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var ary = ToIntArray(input.ReadLine(), n);
long c = 0;
foreach (var a in ary) {
if (a % 2 == 1)
continue;
var ax = a;
while (ax != 1) {
ax /= 2;
c++;
}
}
return c;
}
static long[] ToIntArray(string strs, int n) {
var ret = new long[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = long.Parse(spl[i]);
return ret;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program {
const string Yes = "Yes";
const string No = "No";
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var ary = ToIntArray(input.ReadLine(), n);
long c = 0;
foreach (var a in ary) {
if (a % 2 == 1)
continue;
var ax = a;
while (ax % 2 == 0) {
ax /= 2;
c++;
}
}
return c;
}
static long[] ToIntArray(string strs, int n) {
var ret = new long[n];
var spl = strs.Split(' ');
for (int i = 0; i < n; i++)
ret[i] = long.Parse(spl[i]);
return ret;
}
}
|
[["-", 0, 210, 8, 196, 0, 52, 15, 16, 17, 79], ["-", 0, 210, 8, 196, 0, 52, 15, 16, 12, 203], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 17, 109], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 12, 203], ["+", 0, 210, 8, 196, 0, 52, 15, 16, 17, 60], ["+", 0, 210, 8, 196, 0, 52, 15, 16, 12, 203]]
| 8
| 281
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp28 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans = 0;
foreach (var element in a) {
ans += CountTwoFactor(element);
}
Console.WriteLine(ans);
}
static int CountTwoFactor(int a_) {
int cnt = 0;
while (cnt % 2 == 0) {
a_ /= 2;
cnt++;
}
return cnt;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp28 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans = 0;
foreach (var element in a) {
ans += CountTwoFactor(element);
}
Console.WriteLine(ans);
}
static int CountTwoFactor(int a_) {
int cnt = 0;
while (a_ % 2 == 0) {
a_ /= 2;
cnt++;
}
return cnt;
}
}
}
|
[["-", 8, 196, 0, 52, 15, 16, 31, 16, 31, 22], ["+", 8, 196, 0, 52, 15, 16, 31, 16, 31, 22]]
| 8
| 146
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var n = ReadLib.ReadAsInt();
var aArr = ReadLib.ReadAsIntArray();
var aArrMax = aArr.Max();
var cnt = 0;
for (var i = 0; i < n; i++) {
while (aArr[i] % 2 == 0 && aArr[i] > 0) {
aArr[i] %= 2;
cnt++;
}
}
Console.WriteLine(cnt);
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
/// <summary>nCr, 組み合わせ</summary>
public static long Combination(int n, int r) {
if (r == 0) {
return 1;
}
// 分子
var moleculeArr =
Enumerable.Range(0, Math.Min(n - r, r)).Select(i => n - i).ToArray();
var moleculeArrLength = moleculeArr.Length;
// 分母
var denominatorArr = Enumerable.Range(1, Math.Max(n - r, r)).ToArray();
for (var m = 0; m < moleculeArrLength; m++) {
while (true) {
var mVal = moleculeArr[m];
var gcds = denominatorArr.Select(b => Gcd(mVal, b));
var maxGcd = gcds.Max();
var maxI = gcds.ToList().IndexOf(maxGcd);
if (maxGcd == 1) {
break;
}
denominatorArr[maxI] /= maxGcd;
moleculeArr[m] /= maxGcd;
}
}
return FullPower(moleculeArr);
}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static int Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
var mod = a % b;
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return (int)b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)(value % mod);
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
long value = item1.Value + item2;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
long value = Math.BigMul(item1.Value, item2);
return new ModInt(value, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
#if !DEBUG
using System.IO;
#endif
public class Program {
public static void Main() {
#region SetAutoFlushIsFalse
#if !DEBUG
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
#endif
#endregion
var n = ReadLib.ReadAsInt();
var aArr = ReadLib.ReadAsIntArray();
var aArrMax = aArr.Max();
var cnt = 0;
for (var i = 0; i < n; i++) {
while (aArr[i] % 2 == 0 && aArr[i] > 0) {
aArr[i] /= 2;
cnt++;
}
}
Console.WriteLine(cnt);
#region Flush
#if !DEBUG
Console.Out.Flush();
sw.Close();
#endif
#endregion
}
}
static class ReadLib {
public static long ReadAsLong() { return long.Parse(Console.ReadLine()); }
public static int ReadAsInt() { return int.Parse(Console.ReadLine()); }
public static int[] ReadAsIntArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s) + step)
.ToArray();
}
public static long[] ReadAsLongArray(int step = 0) {
return Console.ReadLine()
.Split(' ')
.Select(s => long.Parse(s) + step)
.ToArray();
}
public static ulong[] ReadAsULongArray() {
return Console.ReadLine().Split(' ').Select(s => ulong.Parse(s)).ToArray();
}
public static string[] ReadAsStringArray() {
return Console.ReadLine().Split(' ');
}
public static int[] ReadNTimesAsInt(int n, int step = 0) {
return Enumerable.Range(1, n)
.Select(s => int.Parse(Console.ReadLine()) + step)
.ToArray();
}
public static int[][] ReadNTimesAsIntArray(int n, int step = 0) {
return Enumerable.Range(1, n).Select(s => ReadAsIntArray(step)).ToArray();
}
public static string[] ReadNTimesAsString(int n) {
return Enumerable.Range(1, n).Select(s => Console.ReadLine()).ToArray();
}
}
static class MyMath {
/// <summary>階乗</summary>
public static long Factorial(int n) {
if (n == 0) {
return 1;
}
return Permutation(n, 0);
}
public static long Permutation(int n, int k) {
return Enumerable.Range(0, n - k)
.Select(i => n - i)
.Aggregate(1, (b, i) => b * i);
}
/// <summary>nCr, 組み合わせ</summary>
public static long Combination(int n, int r) {
if (r == 0) {
return 1;
}
// 分子
var moleculeArr =
Enumerable.Range(0, Math.Min(n - r, r)).Select(i => n - i).ToArray();
var moleculeArrLength = moleculeArr.Length;
// 分母
var denominatorArr = Enumerable.Range(1, Math.Max(n - r, r)).ToArray();
for (var m = 0; m < moleculeArrLength; m++) {
while (true) {
var mVal = moleculeArr[m];
var gcds = denominatorArr.Select(b => Gcd(mVal, b));
var maxGcd = gcds.Max();
var maxI = gcds.ToList().IndexOf(maxGcd);
if (maxGcd == 1) {
break;
}
denominatorArr[maxI] /= maxGcd;
moleculeArr[m] /= maxGcd;
}
}
return FullPower(moleculeArr);
}
#region FullPower
/// <summary>総乗、π</summary>
public static long FullPower(IEnumerable<long> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
public static long FullPower(IEnumerable<int> vs) {
return vs.Aggregate(1L, (a, b) => a * b);
}
#endregion
/// <summary>最大公約数</summary>
public static int Gcd(long item1, long item2) {
var a = Math.Max(item1, item2);
var b = Math.Min(item1, item2);
while (true) {
var mod = a % b;
if (mod == 0) {
break;
}
a = b;
b = mod;
}
return (int)b;
}
/// <summary>約分。最大公約数で割ったものを返す。</summary>
public static Tuple<long, long> DeviedByGcd(long item1, long item2) {
var gcd = Gcd(item1, item2);
return new Tuple<long, long>(item1 / gcd, item2 / gcd);
}
}
static class MyMethod {
/// <summary>数え上げて、key, 出現回数に変換</summary>
public static Dictionary<T, int> CountUp<T>(IEnumerable<T> str) {
return str.GroupBy(c => c)
.Select(g => new KeyValuePair<T, int>(g.Key, g.Count()))
.ToDictionary(e => e.Key, e => e.Value);
}
}
/// <summary>あまりを計算するためのintのラッパー</summary>
struct ModInt {
int Value { get; }
int Mod { get; }
public override string ToString() { return Value.ToString(); }
public static explicit operator ModInt(long value) {
return new ModInt(value);
}
public ModInt(long value, int mod = 1000000007) {
this.Value = (int)(value % mod);
this.Mod = mod;
}
public static explicit operator int(ModInt modInt) { return modInt.Value; }
private static void CheckNotEqualMod(ModInt item1, ModInt item2) {
if (item1.Mod != item2.Mod) {
throw new Exception("mod not equal");
}
}
public static ModInt operator +(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = item1.Value + item2.Value;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, ModInt item2) {
CheckNotEqualMod(item1, item2);
long value = Math.BigMul(item1.Value, item2.Value);
return new ModInt(value, item1.Mod);
}
public static ModInt operator +(ModInt item1, int item2) {
long value = item1.Value + item2;
return new ModInt(value, item1.Mod);
}
public static ModInt operator *(ModInt item1, int item2) {
long value = Math.BigMul(item1.Value, item2);
return new ModInt(value, item1.Mod);
}
public override int GetHashCode() { return this.Value; }
public override bool Equals(object obj) {
if (obj == null || this.GetType() != obj.GetType()) {
return false;
}
var modIntObj = (ModInt)obj;
return modIntObj.Value == this.Value;
}
public static bool operator ==(ModInt item1, ModInt item2) {
return item1.Value == item2.Value;
}
public static bool operator !=(ModInt item1, ModInt item2) {
return !(item1 == item2);
}
public static bool operator ==(ModInt item1, int item2) {
return item1.Value == item2;
}
public static bool operator !=(ModInt item1, int item2) {
return !(item1.Value == item2);
}
public static bool operator >=(ModInt item1, ModInt item2) {
return item1.Value >= item2.Value;
}
public static bool operator <=(ModInt item1, ModInt item2) {
return item1.Value <= item2.Value;
}
public static bool operator >=(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator <=(ModInt item1, int item2) {
return item1.Value <= item2;
}
public static bool operator>(ModInt item1, ModInt item2) {
return item1.Value > item2.Value;
}
public static bool operator<(ModInt item1, ModInt item2) {
return item1.Value < item2.Value;
}
public static bool operator>(ModInt item1, int item2) {
return item1.Value >= item2;
}
public static bool operator<(ModInt item1, int item2) {
return item1.Value <= item2;
}
}
|
[["-", 8, 196, 0, 1, 0, 11, 0, 202, 0, 132], ["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 90]]
| 8
| 1,683
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
struct input {
public long N;
public long M;
}
struct Cake {
public long x;
public long y;
public long z;
public Cake(long _x, long _y, long _z) {
x = _x;
y = _y;
z = _z;
}
}
class MainClass {
static input input;
public static void Main(string[] args) {
var temp = Console.ReadLine().Split(' ').Select(int.Parse);
input.N = temp.ElementAt(0);
input.M = temp.ElementAt(1);
var cakeList = new List<Cake>();
var ansList = new List<long>();
for (var i = 0; i < input.N; i++) {
var temp2 = Console.ReadLine().Split(' ').Select(long.Parse);
cakeList.Add(
new Cake(temp2.ElementAt(0), temp2.ElementAt(1), temp2.ElementAt(2)));
}
//正正正
cakeList =
cakeList.OrderByDescending(e => { return e.x + e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x + e.y + e.z; }));
//正正負
cakeList =
cakeList.OrderByDescending(e => { return e.x + e.y - e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x + e.y - e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return e.x - e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x - e.y + e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return e.x - e.y - e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x - e.y - e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x + e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x + e.y + e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x - e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x - e.y + e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x - e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x - e.y + e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x - e.y - e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x - e.y - e.z; }));
// ansList.Add(cakeList.ForEach(e => Console.WriteLine(e.x));
Console.WriteLine(ansList.Max());
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
struct input {
public long N;
public long M;
}
struct Cake {
public long x;
public long y;
public long z;
public Cake(long _x, long _y, long _z) {
x = _x;
y = _y;
z = _z;
}
}
class MainClass {
static input input;
public static void Main(string[] args) {
var temp = Console.ReadLine().Split(' ').Select(int.Parse);
input.N = temp.ElementAt(0);
input.M = temp.ElementAt(1);
var cakeList = new List<Cake>();
var ansList = new List<long>();
for (var i = 0; i < input.N; i++) {
var temp2 = Console.ReadLine().Split(' ').Select(long.Parse);
cakeList.Add(
new Cake(temp2.ElementAt(0), temp2.ElementAt(1), temp2.ElementAt(2)));
}
//正正正
cakeList =
cakeList.OrderByDescending(e => { return e.x + e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x + e.y + e.z; }));
//正正負
cakeList =
cakeList.OrderByDescending(e => { return e.x + e.y - e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x + e.y - e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return e.x - e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x - e.y + e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return e.x - e.y - e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return e.x - e.y - e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x + e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x + e.y + e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x + e.y - e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x + e.y - e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x - e.y + e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x - e.y + e.z; }));
cakeList =
cakeList.OrderByDescending(e => { return -e.x - e.y - e.z; }).ToList();
ansList.Add(
cakeList.Take((int)input.M).Sum(e => { return -e.x - e.y - e.z; }));
// ansList.Add(cakeList.ForEach(e => Console.WriteLine(e.x));
Console.WriteLine(ansList.Max());
}
}
|
[["-", 8, 196, 0, 37, 0, 16, 31, 16, 17, 33], ["+", 8, 196, 0, 37, 0, 16, 31, 16, 17, 72], ["-", 0, 218, 8, 196, 0, 37, 0, 16, 17, 72], ["+", 0, 218, 8, 196, 0, 37, 0, 16, 17, 33]]
| 8
| 785
| 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();
//各方向探索
long[] x = new long[N];
long[] y = new long[N];
long[] z = new long[N];
for (int i = 0; i < N; i++) {
x[i] = NextLong();
y[i] = NextLong();
z[i] = NextLong();
}
long ans = 0;
int m = (int)Math.Pow(2, 3);
for (int bit = 0; bit < m; bit++) {
PriorityQueue<long, long> PQ = new PriorityQueue<long, long>(false);
for (int i = 0; i < N; i++) {
long score = 0;
if ((1 & bit >> 0) == 1)
score += x[i];
else
score -= x[i];
if ((1 & bit >> 1) == 1)
score += y[i];
else
score -= y[i];
if ((1 & bit >> 2) == 1)
score += z[i];
else
score -= z[i];
PQ.Enqueue(score, score);
}
long sum = 0;
for (int i = 0; i < M; i++) {
long score = PQ.Dequeue();
sum += Math.Abs(score);
}
ans = Math.Max(ans, sum);
}
Console.WriteLine(ans);
}
}
public class PriorityQueue<Tkey, Tvalue>
where Tkey : IComparable {
private static List<Tkey> list = new List<Tkey>();
private static List<Tvalue> value = new List<Tvalue>();
public int Count { get; private set; } = 0;
private static bool Descending;
public PriorityQueue(bool b = true) {
Descending = b;
list = new List<Tkey>();
value = new List<Tvalue>();
}
private static int Compare(Tkey a, Tkey b) {
if (Descending)
return a.CompareTo(b);
else
return b.CompareTo(a);
}
public void Enqueue(Tkey e, Tvalue n) {
Count++;
int now = Count - 1;
list.Add(e);
value.Add(n);
while (now != 0) {
int par = (now - 1) / 2;
if (Compare(list[par], e) <= 0)
break;
Tkey a = list[now];
list[now] = list[par];
list[par] = a;
Tvalue b = value[now];
value[now] = value[par];
value[par] = b;
now = par;
}
}
public Tvalue Dequeue() {
if (Count == 0)
return (Tvalue)(object)(-1);
Tvalue e = value.First();
if (Count == 1) {
list = new List<Tkey>();
value = new List<Tvalue>();
Count--;
return e;
}
Tkey x = list[Count - 1];
Tvalue y = value[Count - 1];
int i = 0;
while (i * 2 + 1 < Count) {
int l = i * 2 + 1;
int r = i * 2 + 2;
if (r < Count && Compare(list[r], list[l]) < 0)
l = r;
if (Compare(list[l], x) >= 0)
break;
list[i] = list[l];
value[i] = value[l];
i = l;
}
list[i] = x;
value[i] = y;
Count--;
return e;
}
}
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() {
int N = NextInt();
int M = NextInt();
//各方向探索
long[] x = new long[N];
long[] y = new long[N];
long[] z = new long[N];
for (int i = 0; i < N; i++) {
x[i] = NextLong();
y[i] = NextLong();
z[i] = NextLong();
}
long ans = 0;
int m = (int)Math.Pow(2, 3);
for (int bit = 0; bit < m; bit++) {
PriorityQueue<long, long> PQ = new PriorityQueue<long, long>(false);
for (int i = 0; i < N; i++) {
long score = 0;
if ((1 & bit >> 0) == 1)
score += x[i];
else
score -= x[i];
if ((1 & bit >> 1) == 1)
score += y[i];
else
score -= y[i];
if ((1 & bit >> 2) == 1)
score += z[i];
else
score -= z[i];
PQ.Enqueue(score, score);
}
long sum = 0;
for (int i = 0; i < M; i++) {
long score = PQ.Dequeue();
sum += score;
}
ans = Math.Max(ans, sum);
}
Console.WriteLine(ans);
}
}
public class PriorityQueue<Tkey, Tvalue>
where Tkey : IComparable {
private static List<Tkey> list = new List<Tkey>();
private static List<Tvalue> value = new List<Tvalue>();
public int Count { get; private set; } = 0;
private static bool Descending;
public PriorityQueue(bool b = true) {
Descending = b;
list = new List<Tkey>();
value = new List<Tvalue>();
}
private static int Compare(Tkey a, Tkey b) {
if (Descending)
return a.CompareTo(b);
else
return b.CompareTo(a);
}
public void Enqueue(Tkey e, Tvalue n) {
Count++;
int now = Count - 1;
list.Add(e);
value.Add(n);
while (now != 0) {
int par = (now - 1) / 2;
if (Compare(list[par], e) <= 0)
break;
Tkey a = list[now];
list[now] = list[par];
list[par] = a;
Tvalue b = value[now];
value[now] = value[par];
value[par] = b;
now = par;
}
}
public Tvalue Dequeue() {
if (Count == 0)
return (Tvalue)(object)(-1);
Tvalue e = value.First();
if (Count == 1) {
list = new List<Tkey>();
value = new List<Tvalue>();
Count--;
return e;
}
Tkey x = list[Count - 1];
Tvalue y = value[Count - 1];
int i = 0;
while (i * 2 + 1 < Count) {
int l = i * 2 + 1;
int r = i * 2 + 2;
if (r < Count && Compare(list[r], list[l]) < 0)
l = r;
if (Compare(list[l], x) >= 0)
break;
list[i] = list[l];
value[i] = value[l];
i = l;
}
list[i] = x;
value[i] = y;
Count--;
return e;
}
}
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, 1, 0, 11, 12, 213, 63, 214, 205, 22], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24], ["-", 0, 1, 0, 11, 12, 213, 3, 4, 0, 25]]
| 8
| 1,111
| 5
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
int M = cin.nextInt();
long[] x = new long[N];
long[] y = new long[N];
long[] z = new long[N];
for (int i = 0; i < N; i++) {
x[i] = cin.nextInt();
y[i] = cin.nextInt();
z[i] = cin.nextInt();
}
long ans = 0;
for (int a = -1; a <= 1; a += 2) {
for (int b = -1; b <= 1; b += 2) {
for (int c = -1; c <= 1; c += 2) {
List<long> l = new List<long>();
for (int i = 0; i < N; i++) {
l.Add(x[i] * a + y[i] * b + z[i] * c);
}
l.Sort();
l.Reverse();
long tmp = 0;
for (int i = 0; i < M; i++) {
tmp += l[i];
}
ans = Math.Max(ans, tmp);
}
}
}
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;
class Myon {
public Myon() {}
public static int Main() {
new Myon().calc();
return 0;
}
Scanner cin;
void calc() {
cin = new Scanner();
int N = cin.nextInt();
int M = cin.nextInt();
long[] x = new long[N];
long[] y = new long[N];
long[] z = new long[N];
for (int i = 0; i < N; i++) {
x[i] = cin.nextLong();
y[i] = cin.nextLong();
z[i] = cin.nextLong();
}
long ans = 0;
for (int a = -1; a <= 1; a += 2) {
for (int b = -1; b <= 1; b += 2) {
for (int c = -1; c <= 1; c += 2) {
List<long> l = new List<long>();
for (int i = 0; i < N; i++) {
l.Add(x[i] * a + y[i] * b + z[i] * c);
}
l.Sort();
l.Reverse();
long tmp = 0;
for (int i = 0; i < M; i++) {
tmp += l[i];
}
ans = Math.Max(ans, tmp);
}
}
}
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
}
|
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22]]
| 8
| 716
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgrammingContest {
class Writer : IDisposable {
private readonly System.IO.TextWriter writer;
private StringBuilder sb;
private readonly bool isReactive;
public Writer(string path) : this(new System.IO.StreamWriter(path)) {}
public Writer(bool isReactive) : this(null, isReactive) {}
public Writer(System.IO.TextWriter writer = null, bool isReactive = false) {
this.writer = (writer ?? Console.Out);
this.isReactive = isReactive;
if (!this.isReactive) {
this.sb = new StringBuilder();
}
}
public void Dispose() {
if (!this.isReactive) {
this.writer.Write(sb.ToString());
}
if (!this.writer.Equals(Console.Out)) {
this.writer.Dispose();
}
}
public void Write(object val) {
if (this.isReactive) {
this.writer.Write(val.ToString());
this.writer.Flush();
} else {
this.sb.Append(val.ToString());
}
}
public void Write(string format, params object[] vals) {
if (this.isReactive) {
this.writer.Write(format, vals);
this.writer.Flush();
} else {
this.sb.AppendFormat(format, vals);
}
}
public void WriteLine(object val = null) {
this.Write((val ?? string.Empty).ToString() + System.Environment.NewLine);
}
public void WriteLine(int val) { this.WriteLine(val.ToString()); }
public void WriteLine(long val) { this.WriteLine(val.ToString()); }
public void WriteLine(string val) { this.WriteLine((object)val); }
public void WriteLine(string format, params object[] vals) {
this.Write(format + System.Environment.NewLine, vals);
}
}
class Scanner : IDisposable {
private readonly Queue<string> buffer;
private readonly char[] sep;
private readonly System.IO.TextReader reader;
public Scanner(string path, char[] sep = null)
: this(new System.IO.StreamReader(path), sep) {}
public Scanner(System.IO.TextReader reader = null, char[] sep = null) {
this.buffer = new Queue<string>();
this.sep = (sep ?? new char[] { ' ' });
this.reader = (reader ?? Console.In);
}
private void CheckBuffer() {
if (this.buffer.Count == 0 && this.reader.Peek() != -1) {
string str = string.Empty;
for (; string.IsNullOrEmpty(str); str = this.reader.ReadLine())
;
str.Split(this.sep).ToList().ForEach(el => this.buffer.Enqueue(el));
}
}
public void Dispose() {
if (!this.reader.Equals(Console.In)) {
this.reader.Dispose();
}
}
public string Next {
get {
this.CheckBuffer();
return this.buffer.Dequeue();
}
}
public string[] GetStringArray(int N) {
return Enumerable.Range(0, N).Select(e => this.Next).ToArray();
}
public int NextInt {
get { return int.Parse(this.Next); }
}
public int[] GetIntArray(int N) {
return Enumerable.Range(0, N).Select(e => this.NextInt).ToArray();
}
public double NextDouble {
get { return double.Parse(this.Next); }
}
public double[] GetdoubleArray(int N) {
return Enumerable.Range(0, N).Select(e => this.NextDouble).ToArray();
}
public long NextLong {
get { return long.Parse(this.Next); }
}
public long[] GetLongArray(int N) {
return Enumerable.Range(0, N).Select(e => this.NextLong).ToArray();
}
public bool IsEnd {
get {
this.CheckBuffer();
return this.buffer.Count == 0;
}
}
}
class MainClass : IDisposable {
Scanner sc;
Writer wr;
const string backPath = "..";
private readonly char dirSep = System.IO.Path.DirectorySeparatorChar;
private readonly string inFilePath = string.Empty;
private readonly string outFilePath = string.Empty;
public MainClass() {
this.inFilePath = MainClass.backPath + this.dirSep + MainClass.backPath +
this.dirSep + "in.txt";
this.outFilePath = MainClass.backPath + this.dirSep + MainClass.backPath +
this.dirSep + "out.txt";
this.wr = new Writer(this.IsReactive);
// this.wr = new Writer(this.outFilePath);
#if DEBUG
if (!this.IsReactive) {
this.sc = new Scanner(this.inFilePath);
} else {
this.sc = new Scanner();
}
#else
this.sc = new Scanner();
#endif
}
static void Main(string[] args) {
using (var mainClass = new MainClass()) { mainClass.Solve(); }
}
public void Dispose() {
if (this.sc != null) {
this.sc.Dispose();
this.sc = null;
}
if (this.wr != null) {
this.wr.Dispose();
this.wr = null;
}
#if DEBUG
Console.WriteLine("続行するには何かキーを押してください...");
Console.ReadKey();
#endif
}
void MakeTestCase() {
var rand = new Random();
if (this.wr != null) {
this.wr.Dispose();
}
this.wr = new Writer(inFilePath);
}
void Solve() {
int N = sc.NextInt;
int M = sc.NextInt;
long[] x = new long[N];
long[] y = new long[N];
long[] z = new long[N];
for (int i = 0; i < N; i++) {
x[i] = sc.NextLong;
y[i] = sc.NextLong;
z[i] = sc.NextLong;
}
long ans = 0;
for (int f = 0; f < (1 << 3); f++) {
if ((f & 1) != 0) {
for (int i = 0; i < N; i++) {
x[i] *= -1;
}
}
if ((f & (1 << 1)) != 0) {
for (int i = 0; i < N; i++) {
y[i] *= -1;
}
}
if ((f & (1 << 2)) != 0) {
for (int i = 0; i < N; i++) {
z[i] *= -1;
}
}
long[] dp = Enumerable.Range(0, M + 1).Select(e => -1L).ToArray();
dp[0] = 0;
for (int i = 0; i < N; i++) {
for (int j = M - 1; j >= 0; j--) {
if (dp[j] > -1) {
dp[j + 1] = Math.Max(dp[j + 1], dp[j] + x[i] + y[i] + z[i]);
}
}
}
ans = Math.Max(ans, dp[M]);
if ((f & 1) != 0) {
for (int i = 0; i < N; i++) {
x[i] *= -1;
}
}
if ((f & (1 << 1)) != 0) {
for (int i = 0; i < N; i++) {
y[i] *= -1;
}
}
if ((f & (1 << 2)) != 0) {
for (int i = 0; i < N; i++) {
z[i] *= -1;
}
}
}
wr.WriteLine(ans);
}
private bool IsReactive { get; } = false; // TODO: reactive check !!
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ProgrammingContest {
class Writer : IDisposable {
private readonly System.IO.TextWriter writer;
private StringBuilder sb;
private readonly bool isReactive;
public Writer(string path) : this(new System.IO.StreamWriter(path)) {}
public Writer(bool isReactive) : this(null, isReactive) {}
public Writer(System.IO.TextWriter writer = null, bool isReactive = false) {
this.writer = (writer ?? Console.Out);
this.isReactive = isReactive;
if (!this.isReactive) {
this.sb = new StringBuilder();
}
}
public void Dispose() {
if (!this.isReactive) {
this.writer.Write(sb.ToString());
}
if (!this.writer.Equals(Console.Out)) {
this.writer.Dispose();
}
}
public void Write(object val) {
if (this.isReactive) {
this.writer.Write(val.ToString());
this.writer.Flush();
} else {
this.sb.Append(val.ToString());
}
}
public void Write(string format, params object[] vals) {
if (this.isReactive) {
this.writer.Write(format, vals);
this.writer.Flush();
} else {
this.sb.AppendFormat(format, vals);
}
}
public void WriteLine(object val = null) {
this.Write((val ?? string.Empty).ToString() + System.Environment.NewLine);
}
public void WriteLine(int val) { this.WriteLine(val.ToString()); }
public void WriteLine(long val) { this.WriteLine(val.ToString()); }
public void WriteLine(string val) { this.WriteLine((object)val); }
public void WriteLine(string format, params object[] vals) {
this.Write(format + System.Environment.NewLine, vals);
}
}
class Scanner : IDisposable {
private readonly Queue<string> buffer;
private readonly char[] sep;
private readonly System.IO.TextReader reader;
public Scanner(string path, char[] sep = null)
: this(new System.IO.StreamReader(path), sep) {}
public Scanner(System.IO.TextReader reader = null, char[] sep = null) {
this.buffer = new Queue<string>();
this.sep = (sep ?? new char[] { ' ' });
this.reader = (reader ?? Console.In);
}
private void CheckBuffer() {
if (this.buffer.Count == 0 && this.reader.Peek() != -1) {
string str = string.Empty;
for (; string.IsNullOrEmpty(str); str = this.reader.ReadLine())
;
str.Split(this.sep).ToList().ForEach(el => this.buffer.Enqueue(el));
}
}
public void Dispose() {
if (!this.reader.Equals(Console.In)) {
this.reader.Dispose();
}
}
public string Next {
get {
this.CheckBuffer();
return this.buffer.Dequeue();
}
}
public string[] GetStringArray(int N) {
return Enumerable.Range(0, N).Select(e => this.Next).ToArray();
}
public int NextInt {
get { return int.Parse(this.Next); }
}
public int[] GetIntArray(int N) {
return Enumerable.Range(0, N).Select(e => this.NextInt).ToArray();
}
public double NextDouble {
get { return double.Parse(this.Next); }
}
public double[] GetdoubleArray(int N) {
return Enumerable.Range(0, N).Select(e => this.NextDouble).ToArray();
}
public long NextLong {
get { return long.Parse(this.Next); }
}
public long[] GetLongArray(int N) {
return Enumerable.Range(0, N).Select(e => this.NextLong).ToArray();
}
public bool IsEnd {
get {
this.CheckBuffer();
return this.buffer.Count == 0;
}
}
}
class MainClass : IDisposable {
Scanner sc;
Writer wr;
const string backPath = "..";
private readonly char dirSep = System.IO.Path.DirectorySeparatorChar;
private readonly string inFilePath = string.Empty;
private readonly string outFilePath = string.Empty;
public MainClass() {
this.inFilePath = MainClass.backPath + this.dirSep + MainClass.backPath +
this.dirSep + "in.txt";
this.outFilePath = MainClass.backPath + this.dirSep + MainClass.backPath +
this.dirSep + "out.txt";
this.wr = new Writer(this.IsReactive);
// this.wr = new Writer(this.outFilePath);
#if DEBUG
if (!this.IsReactive) {
this.sc = new Scanner(this.inFilePath);
} else {
this.sc = new Scanner();
}
#else
this.sc = new Scanner();
#endif
}
static void Main(string[] args) {
using (var mainClass = new MainClass()) { mainClass.Solve(); }
}
public void Dispose() {
if (this.sc != null) {
this.sc.Dispose();
this.sc = null;
}
if (this.wr != null) {
this.wr.Dispose();
this.wr = null;
}
#if DEBUG
Console.WriteLine("続行するには何かキーを押してください...");
Console.ReadKey();
#endif
}
void MakeTestCase() {
var rand = new Random();
if (this.wr != null) {
this.wr.Dispose();
}
this.wr = new Writer(inFilePath);
}
void Solve() {
int N = sc.NextInt;
int M = sc.NextInt;
long[] x = new long[N];
long[] y = new long[N];
long[] z = new long[N];
for (int i = 0; i < N; i++) {
x[i] = sc.NextLong;
y[i] = sc.NextLong;
z[i] = sc.NextLong;
}
long ans = 0;
for (int f = 0; f < (1 << 3); f++) {
if ((f & 1) != 0) {
for (int i = 0; i < N; i++) {
x[i] *= -1;
}
}
if ((f & (1 << 1)) != 0) {
for (int i = 0; i < N; i++) {
y[i] *= -1;
}
}
if ((f & (1 << 2)) != 0) {
for (int i = 0; i < N; i++) {
z[i] *= -1;
}
}
long[] dp = Enumerable.Range(0, M + 1).Select(e => (long)-1e18).ToArray();
dp[0] = 0;
for (int i = 0; i < N; i++) {
for (int j = M - 1; j >= 0; j--) {
if (dp[j] > -1e18) {
dp[j + 1] = Math.Max(dp[j + 1], dp[j] + x[i] + y[i] + z[i]);
}
}
}
ans = Math.Max(ans, dp[M]);
if ((f & 1) != 0) {
for (int i = 0; i < N; i++) {
x[i] *= -1;
}
}
if ((f & (1 << 1)) != 0) {
for (int i = 0; i < N; i++) {
y[i] *= -1;
}
}
if ((f & (1 << 2)) != 0) {
for (int i = 0; i < N; i++) {
z[i] *= -1;
}
}
}
wr.WriteLine(ans);
}
private bool IsReactive { get; } = false; // TODO: reactive check !!
}
}
|
[["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 218, 8, 74, 0, 25], ["-", 3, 4, 0, 28, 0, 218, 8, 241, 0, 203], ["+", 0, 28, 0, 218, 8, 74, 51, 241, 0, 250], ["-", 8, 196, 0, 57, 15, 16, 12, 241, 0, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 250]]
| 8
| 1,718
| 7
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
Console.WriteLine(n > 999 ? "ABC" : "ABC");
}
}
}
|
using System;
using System.Linq;
namespace A {
class Program {
static void Main(string[] args) {
var n = int.Parse(Console.ReadLine());
Console.WriteLine(n > 999 ? "ABD" : "ABC");
}
}
}
|
[["-", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 222]]
| 8
| 58
| 2
|
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 N = ReadInt();
if (N < 1000)
Println($"ABC{N:000}");
else
Println($"ABD{N-999:000}");
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
namespace ConsoleApp1 {
class Program {
static void Main(string[] args) { A(); }
static void A() {
var N = ReadInt();
if (N < 1000)
Println("ABC");
else
Println("ABD");
}
static List<long> ReadLines(long n) {
var l = new List<long>();
for (long i = 0; i < n; i++) {
l.Add(ReadLong());
}
return l;
}
static IEnumerable<int> Range(int start, int stop) {
if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
return new List<int>();
return Enumerable.Range(start, stop - start);
}
static bool IsDigit(string str) {
var i = 0;
return int.TryParse(str, out i);
}
static int SumDigits(long num) {
return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
}
static int[] ToIntArray(string str) {
return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
}
static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
static long Lcm(long a, long b) => a / Gcd(a, b) * b;
static bool IsPrime(int x) {
if (x <= 1 || (x != 2 && x % 2 == 0))
return false;
if (x == 2)
return true;
for (int i = 3; i < x; i += 2)
if (x % i == 0)
return false;
return true;
}
static string Read() => Console.ReadLine();
static int ReadInt() => int.Parse(Read());
static long ReadLong() => long.Parse(Read());
static List<string> ReadSplit() => Read().Split().ToList();
static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
static List<long>
ReadSplitLong() => Read().Split().Select(long.Parse).ToList();
static void Print(object value) => Console.Write(value.ToString());
static void Println(object value) => Console.WriteLine(value.ToString());
static string Join<T>(IEnumerable<T> list) => string.Join("", list);
}
public static class MyExtensions {
public static string Slice(this string str, int start = 0, int stop = 0) {
if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
return "";
if (stop == 0)
stop = str.Length;
return str.Substring(start, stop - start);
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 283, 0, 295], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 62], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 45], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 22], ["-", 0, 28, 0, 283, 0, 284, 0, 298, 0, 102], ["-", 3, 4, 0, 28, 0, 283, 0, 284, 0, 46], ["-", 0, 28, 0, 283, 0, 284, 0, 16, 31, 22], ["-", 0, 28, 0, 283, 0, 284, 0, 16, 17, 33], ["-", 0, 28, 0, 283, 0, 284, 0, 16, 12, 203]]
| 8
| 671
| 16
|
using System;
using static System.Console;
class Program {
public static void Main() {
int n = int.Parse(ReadLine());
if (n < 100) {
WriteLine("ABC");
} else {
WriteLine("ABD");
}
}
}
|
using System;
using static System.Console;
class Program {
public static void Main() {
int n = int.Parse(ReadLine());
if (n < 1000) {
WriteLine("ABC");
} else {
WriteLine("ABD");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 58
| 2
|
using System;
namespace Murasa {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
String con = "AB";
if (N >= 1000) {
N -= 999;
Console.WriteLine(con + "D" + N);
} else {
Console.WriteLine(con + "C" + N);
}
}
}
}
|
using System;
namespace Murasa {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
String con = "AB";
if (N >= 1000) {
N -= 999;
Console.WriteLine(con + "D");
} else {
Console.WriteLine(con + "C");
}
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 72], ["-", 0, 213, 3, 4, 0, 28, 0, 16, 12, 22]]
| 8
| 84
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.