buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _0430_atcoder問題_14 {
class Program {
static void Main(string[] args) {
int hoge = int.Parse(Console.ReadLine());
if (hoge % 2 == 0) {
Console.WriteLine((hoge / 2) * (hoge / 2));
} else {
Console.WriteLine((hoge / 2 - 0.5) * (hoge / 2 + 0.5));
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _0430_atcoder問題_14 {
class Program {
static void Main(string[] args) {
int hoge = int.Parse(Console.ReadLine());
if (hoge % 2 == 0) {
Console.WriteLine((hoge / 2) * (hoge / 2));
} else {
Console.WriteLine((hoge / 2) * ((hoge / 2) + 1));
}
}
}
}
|
[["-", 0, 28, 0, 16, 31, 23, 0, 16, 17, 33], ["-", 0, 28, 0, 16, 31, 23, 0, 16, 12, 250], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 16, 12, 23, 0, 16, 31, 23, 0, 25], ["-", 0, 28, 0, 16, 12, 23, 0, 16, 12, 250], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 12, 203]]
| 8
| 113
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
int K = int.Parse(Console.ReadLine());
if (K % 2 == 1) {
Console.WriteLine((K / 2) * (K / 2 + 1));
} else {
Console.WriteLine((K / 2) ^ 2);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
int K = int.Parse(Console.ReadLine());
if (K % 2 == 1) {
Console.WriteLine((K / 2) * (K / 2 + 1));
} else {
Console.WriteLine((K / 2) * (K / 2));
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 16, 17, 140], ["+", 0, 213, 3, 4, 0, 28, 0, 16, 17, 48], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 24], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 28, 0, 16, 12, 23, 0, 16, 17, 85], ["+", 3, 4, 0, 28, 0, 16, 12, 23, 0, 25]]
| 8
| 101
| 6
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
static void Main(string[] args) {
var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x1 = line[0], y1 = line[1], x2 = line[2], y2 = line[3];
int x3 = 0, y3 = 0, x4 = 0, y4 = 0;
var demX = Math.Abs(x2 - x1);
var demY = Math.Abs(y2 - y1);
if (x1 <= x2 && y1 > y2) {
x3 = x2 + demY;
y3 = y2 + demX;
x4 = x1 + demY;
y4 = y1 + demX;
} else if (x1 <= x2 && y1 < y2) {
x3 = x2 - demY;
y3 = y2 + demX;
x4 = x1 - demY;
y4 = y1 + demX;
} else if (x1 >= x2 && y1 > y2) {
x3 = x2 + demY;
y3 = y2 - demX;
x4 = x1 + demY;
y4 = y1 - demX;
} else if (x1 >= x2 && y1 < y2) {
x3 = x2 - demY;
y3 = y2 - demX;
x4 = x1 - demY;
y4 = y1 - demX;
}
Console.WriteLine($"{x3} {y3} {x4} {y4}");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Algorithm {
class Program {
static void Main(string[] args) {
var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x1 = line[0], y1 = line[1], x2 = line[2], y2 = line[3];
int x3 = 0, y3 = 0, x4 = 0, y4 = 0;
var demX = Math.Abs(x2 - x1);
var demY = Math.Abs(y2 - y1);
if (x1 <= x2 && y1 >= y2) {
x3 = x2 + demY;
y3 = y2 + demX;
x4 = x1 + demY;
y4 = y1 + demX;
} else if (x1 <= x2 && y1 <= y2) {
x3 = x2 - demY;
y3 = y2 + demX;
x4 = x1 - demY;
y4 = y1 + demX;
} else if (x1 >= x2 && y1 >= y2) {
x3 = x2 + demY;
y3 = y2 - demX;
x4 = x1 + demY;
y4 = y1 - demX;
} else if (x1 >= x2 && y1 <= y2) {
x3 = x2 - demY;
y3 = y2 - demX;
x4 = x1 - demY;
y4 = y1 - demX;
}
Console.WriteLine($"{x3} {y3} {x4} {y4}");
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 12, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["-", 0, 57, 75, 57, 15, 16, 12, 16, 17, 18], ["+", 0, 57, 75, 57, 15, 16, 12, 16, 17, 19], ["-", 75, 57, 75, 57, 15, 16, 12, 16, 17, 47], ["+", 75, 57, 75, 57, 15, 16, 12, 16, 17, 20], ["-", 75, 57, 75, 57, 15, 16, 12, 16, 17, 18], ["+", 75, 57, 75, 57, 15, 16, 12, 16, 17, 19]]
| 8
| 298
| 8
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace AtCoder {
class Program {
static void Main() {
var a = ReadIntArray();
int x1 = a[0];
int y1 = a[1];
int x2 = a[2];
int y2 = a[3];
int dirx = x2 - x1;
int diry = y2 - y1;
int x3 = x2 - diry;
int y3 = y2 + dirx;
int x4 = x3 - dirx;
int y4 = y3 + diry;
Console.WriteLine($"{x3}{y3}{x4}{y4}");
}
//ここからテンプレート
// 1行に1入力
private static string ReadString() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(ReadString()); }
private static long ReadLong() { return long.Parse(ReadString()); }
private static double ReadDouble() { return double.Parse(ReadString()); }
// 1行に複数入力(配列で取得)
private static string[] ReadStringArray() {
return ReadString().Split(new[] { ' ' },
System.StringSplitOptions.RemoveEmptyEntries);
}
private static int[] ReadIntArray() {
return ReadStringArray().Select(int.Parse).ToArray();
}
private static long[] ReadLongArray() {
return ReadStringArray().Select(long.Parse).ToArray();
}
private static double[] ReadDoubleArray() {
return ReadStringArray().Select(double.Parse).ToArray();
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
namespace AtCoder {
class Program {
static void Main() {
var a = ReadIntArray();
int x1 = a[0];
int y1 = a[1];
int x2 = a[2];
int y2 = a[3];
int dirx = x2 - x1;
int diry = y2 - y1;
int x3 = x2 - diry;
int y3 = y2 + dirx;
int x4 = x3 - dirx;
int y4 = y3 - diry;
Console.WriteLine($"{x3} {y3} {x4} {y4}");
}
//ここからテンプレート
// 1行に1入力
private static string ReadString() { return Console.ReadLine(); }
private static int ReadInt() { return int.Parse(ReadString()); }
private static long ReadLong() { return long.Parse(ReadString()); }
private static double ReadDouble() { return double.Parse(ReadString()); }
// 1行に複数入力(配列で取得)
private static string[] ReadStringArray() {
return ReadString().Split(new[] { ' ' },
System.StringSplitOptions.RemoveEmptyEntries);
}
private static int[] ReadIntArray() {
return ReadStringArray().Select(int.Parse).ToArray();
}
private static long[] ReadLongArray() {
return ReadStringArray().Select(long.Parse).ToArray();
}
private static double[] ReadDoubleArray() {
return ReadStringArray().Select(double.Parse).ToArray();
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 213, 3, 4, 0, 28, 0, 283, 0, 296]]
| 8
| 324
| 5
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x3 = s[2] - s[3] - s[1];
int y3 = s[3] + s[2] - s[0];
int x4 = x3 - y3 - s[3];
int y4 = y3 + x3 - s[2];
Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);
}
}
|
using System;
using System.Linq;
class Program {
static void Main(string[] args) {
int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
int x3 = s[2] - s[3] + s[1];
int y3 = s[3] + s[2] - s[0];
int x4 = x3 - y3 + s[3];
int y4 = y3 + x3 - s[2];
Console.WriteLine("{0} {1} {2} {3}", x3, y3, x4, y4);
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72]]
| 8
| 126
| 4
|
using System;
using System.Linq;
namespace abc108_b {
class program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int x1 = int.Parse(input[0]);
int y1 = int.Parse(input[1]);
int x2 = int.Parse(input[2]);
int y2 = int.Parse(input[3]);
int x3 = x2 + y1 - y2;
int x4 = x3 - x2 + x1;
int y3 = y2 + x2 - x1;
int y4 = y3 - y1 + y2;
Console.WriteLine(x3 + " " + y3 + " " + x4 + " " + y4);
}
}
}
|
using System;
using System.Linq;
namespace abc108_b {
class program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int x1 = int.Parse(input[0]);
int y1 = int.Parse(input[1]);
int x2 = int.Parse(input[2]);
int y2 = int.Parse(input[3]);
int x3 = x2 + y1 - y2;
int x4 = x3 - x2 + x1;
int y3 = y2 + x2 - x1;
int y4 = y3 + y1 - y2;
Console.WriteLine(x3 + " " + y3 + " " + x4 + " " + y4);
}
}
}
|
[["-", 0, 200, 0, 212, 0, 16, 31, 16, 17, 33], ["-", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 33]]
| 8
| 158
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pair0 {
class Program {
static void Main(string[] args) {
int x1, y1, x2, y2;
string[] str =
Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得
x1 = int.Parse(str[0]); //数値で受け取りたい場合は変換する
y1 = int.Parse(str[1]);
x2 = int.Parse(str[2]);
y2 = int.Parse(str[3]);
int x = x2 - x1;
int y = y2 - y1;
int x3 = x2 - y2;
int y3 = y2 + x;
int x4 = x3 - x;
int y4 = y3 - y2;
Console.Write(x3 + " ");
Console.Write(y3 + " ");
Console.Write(x4 + " ");
Console.WriteLine(y4);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pair0 {
class Program {
static void Main(string[] args) {
int x1, y1, x2, y2;
string[] str =
Console.ReadLine().Split(' '); // 2つ以上のスペース区切り入力の取得
x1 = int.Parse(str[0]); //数値で受け取りたい場合は変換する
y1 = int.Parse(str[1]);
x2 = int.Parse(str[2]);
y2 = int.Parse(str[3]);
int x = x2 - x1;
int y = y2 - y1;
int x3 = x2 - y;
int y3 = y2 + x;
int x4 = x3 - x;
int y4 = y3 - y;
Console.Write(x3 + " ");
Console.Write(y3 + " ");
Console.Write(x4 + " ");
Console.WriteLine(y4);
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
| 8
| 205
| 4
|
using System;
using CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int n = sc.NextInt();
int k = sc.NextInt();
// 全部 kの倍数
// 全部 k/2の倍数
long ans = 0;
if (k % 2 == 0) {
int d = (n - k / 2 + k) / k;
ans += d * d * d;
}
int d2 = n / k;
ans += d2 * d2 * d2;
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 CompLib.Util;
public class Program {
public void Solve() {
var sc = new Scanner();
int n = sc.NextInt();
int k = sc.NextInt();
// 全部 kの倍数
// 全部 k/2の倍数
long ans = 0;
if (k % 2 == 0) {
long d = (n - k / 2 + k) / k;
ans += d * d * d;
}
long d2 = n / k;
ans += d2 * d2 * d2;
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, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 436
| 4
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
const string Yes = "Yes";
const string No = "No";
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../TextFile2.txt");
// MyDebugger.MakeTestCase("../TextFile2.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var k = int.Parse(spl[1]);
var pers = new int[k];
for (int i = 1; i <= n; i++) {
var p = i % k;
pers[p]++;
}
long c = 0;
c += pers[0] * pers[0] * pers[0];
if (k % 2 == 0) {
c += pers[k / 2] * pers[k / 2] * pers[k / 2];
}
return c;
}
}
|
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
class Program {
const string Yes = "Yes";
const string No = "No";
const long Mod = 1000000007;
static void Main(string[] args) {
#if DEBUG
MyDebugger.Test(process, "../TextFile1.txt");
// MyDebugger.Test(process, "../TextFile2.txt");
// MyDebugger.MakeTestCase("../TextFile2.txt");
#else
object ret = process(new StreamReader(Console.OpenStandardInput()));
Console.WriteLine(ret);
#endif
}
static object process(TextReader input) {
var spl = input.ReadLine().Split(' ');
var n = int.Parse(spl[0]);
var k = int.Parse(spl[1]);
var pers = new long[k];
for (int i = 1; i <= n; i++) {
var p = i % k;
pers[p]++;
}
long c = 0;
c += pers[0] * pers[0] * pers[0];
if (k % 2 == 0) {
c += pers[k / 2] * pers[k / 2] * pers[k / 2];
}
return c;
}
}
|
[["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199]]
| 8
| 257
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var waaaa = new waaaa();
waaaa.Solve();
}
}
public class waaaa {
const int MOD = 1000000007;
const long INF = 1 << 61;
const int MOD2 = 998244353;
Scaner cin = new Scaner();
write cout = new write();
Math2 mmath = new Math2();
public void Solve() {
mmath.FactoricalModSet(1000000);
//ここから
var o = cin.IntM;
int N = o[0];
int K = o[1];
long a = N / K;
long b = (N + (K / 2)) / 2;
if (K % 2 == 1) {
cout.wri(a * a * a);
} else
cout.wri(a * a * a + b * b * b);
}
public static bool NextPermutation<T>(T[] array, int start, int length)
where T : IComparable {
int end = start + length - 1;
// 範囲が狭すぎる
if (end <= start)
return false;
int last = end;
while (true) {
int pos = last--;
if (array[last].CompareTo(array[pos]) < 0) {
int i;
for (i = end + 1; array[last].CompareTo(array[--i]) >= 0;) {
}
T tmp = array[last];
array[last] = array[i];
array[i] = tmp;
Array.Reverse(array, pos, end - pos + 1);
return true;
}
if (last == start) // 最後の順列
{
Array.Reverse(array, start, end - start);
return false;
}
}
// ここに来ることはない
throw new Exception("NextPermutation: Fatal error");
}
}
// b-aで降順
// priority queue
class PriorityQueue<T> {
private readonly List<T> heap;
private readonly Comparison<T> compare;
private int size;
public PriorityQueue() : this(Comparer<T>.Default) {}
public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) {}
public PriorityQueue(Comparison<T> comparison) : this(16, comparison) {}
public PriorityQueue(int capacity, Comparison<T> comparison) {
this.heap = new List<T>(capacity);
this.compare = comparison;
}
public void Enqueue(T item) {
this.heap.Add(item);
var i = size++;
while (i > 0) {
var p = (i - 1) >> 1;
if (compare(this.heap[p], item) <= 0)
break;
this.heap[i] = heap[p];
i = p;
}
this.heap[i] = item;
}
public T Dequeue() {
var ret = this.heap[0];
var x = this.heap[--size];
var i = 0;
while ((i << 1) + 1 < size) {
var a = (i << 1) + 1;
var b = (i << 1) + 2;
if (b < size && compare(heap[b], heap[a]) < 0)
a = b;
if (compare(heap[a], x) >= 0)
break;
heap[i] = heap[a];
i = a;
}
heap[i] = x;
heap.RemoveAt(size);
return ret;
}
public T Peek() { return heap[0]; }
public int Count {
get { return size; }
}
public bool Any() { return size > 0; }
}
public class Math2 {
public long[] Fact; // Nまでの階乗
public long[] invFact; //階乗の逆元
// Nまでの階乗をセットしておく
public void FactoricalModSet(long N, long MOD = 1000000007) {
Fact = new long[N + 1];
invFact = new long[N + 1];
Fact[0] = 1;
for (long i = 1; i <= N; ++i) {
Fact[i] = Fact[i - 1] * i % MOD;
}
invFact[N] = pow(Fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invFact[i - 1] = invFact[i] * i % MOD;
}
}
// nCr 引数:n r (mod)
public long nCr(long n, long r, long MOD = 1000000007) {
return (Fact[n] * invFact[r] % MOD * invFact[n - r] % MOD);
}
//階乗(O(logN)) 引数:底x n乗 (MOD)
public long pow(long x, long n, long MOD = 1000000007) {
long res = 1;
while (n > 0) {
if ((n & 1) != 0)
res = res * x % MOD;
x = x * x % MOD;
n >>= 1;
}
return res;
}
//最大公約数 引数:整数x,y
public long GCD(long x, long y) {
while (y != 0) {
var r = x % y;
x = y;
y = r;
}
return x;
}
//最小公倍数 引数:整数x,y
public long LCM(long x, long y) { return x * y / GCD(x, y); }
//素因数分解 引数:整数N
public Dictionary<long, int> PrimeFactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public List<long> PrimeFactorization2(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
}
namespace CompLib.Algorithms {
#region BinarySearch
public static partial class Algorithm {
static int binarySearch<T>(IList<T> a, T v, IComparer<T> cmp, bool islb) {
var l = 0;
var r = a.Count - 1;
while (l <= r) {
var m = (l + r) / 2;
var res = cmp.Compare(a[m], v);
if (res < 0 || (res == 0 && !islb))
l = m + 1;
else
r = m - 1;
}
return l;
}
/// <summary>
/// 与えられた比較関数に従って,<paramref name="a"/> の要素のうち,<paramref
/// name="v"/> 以上の要素であるような最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int LowerBound<T>(this IList<T> a, T v, Comparison<T> f) {
return binarySearch(a, v, Comparer<T>.Create(f), true);
}
/// <summary>
/// デフォルトの比較関数に従って,<paramref name="a"/>
///の要素のうち,<paramref name="v"/>
///以上の要素であるような最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int LowerBound<T>(this IList<T> a, T v) {
return binarySearch(a, v, Comparer<T>.Default, true);
}
/// <summary>
/// 与えられた比較関数に従って,<paramref name="a"/> の要素のうち,<paramref
/// name="v"/> 以上の要素であるような最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int UpperBound<T>(this IList<T> a, T v, Comparison<T> cmp) {
return binarySearch(a, v, Comparer<T>.Create(cmp), false);
}
/// <summary>
/// デフォルトの比較関数に従って,<paramref name="a"/>
///の要素のうち,<paramref name="v"/>
///より真に大きい要素が現れる最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int UpperBound<T>(this IList<T> a, T v) {
return binarySearch(a, v, Comparer<T>.Default, false);
}
}
#endregion
}
class Scaner {
public string Str => Console.ReadLine();
public string[] StrM => Str.Split(' ');
public long[] LongM => StrM.Select(long.Parse).ToArray();
public int[] IntM => StrM.Select(int.Parse).ToArray();
public char[] CharM => Str.ToArray();
public long Long1 => LongM[0];
public int Int1 => IntM[0];
}
class write {
public void wri<T>(T x) { Console.WriteLine(x); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main(string[] args) {
var waaaa = new waaaa();
waaaa.Solve();
}
}
public class waaaa {
const int MOD = 1000000007;
const long INF = 1 << 61;
const int MOD2 = 998244353;
Scaner cin = new Scaner();
write cout = new write();
Math2 mmath = new Math2();
public void Solve() {
mmath.FactoricalModSet(1000000);
//ここから
var o = cin.LongM;
long N = o[0];
long K = o[1];
long a = N / K;
long b = (N + (K / 2)) / K;
if (K % 2 == 1) {
cout.wri(a * a * a);
} else
cout.wri(a * a * a + b * b * b);
}
public static bool NextPermutation<T>(T[] array, int start, int length)
where T : IComparable {
int end = start + length - 1;
// 範囲が狭すぎる
if (end <= start)
return false;
int last = end;
while (true) {
int pos = last--;
if (array[last].CompareTo(array[pos]) < 0) {
int i;
for (i = end + 1; array[last].CompareTo(array[--i]) >= 0;) {
}
T tmp = array[last];
array[last] = array[i];
array[i] = tmp;
Array.Reverse(array, pos, end - pos + 1);
return true;
}
if (last == start) // 最後の順列
{
Array.Reverse(array, start, end - start);
return false;
}
}
// ここに来ることはない
throw new Exception("NextPermutation: Fatal error");
}
}
// b-aで降順
// priority queue
class PriorityQueue<T> {
private readonly List<T> heap;
private readonly Comparison<T> compare;
private int size;
public PriorityQueue() : this(Comparer<T>.Default) {}
public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) {}
public PriorityQueue(Comparison<T> comparison) : this(16, comparison) {}
public PriorityQueue(int capacity, Comparison<T> comparison) {
this.heap = new List<T>(capacity);
this.compare = comparison;
}
public void Enqueue(T item) {
this.heap.Add(item);
var i = size++;
while (i > 0) {
var p = (i - 1) >> 1;
if (compare(this.heap[p], item) <= 0)
break;
this.heap[i] = heap[p];
i = p;
}
this.heap[i] = item;
}
public T Dequeue() {
var ret = this.heap[0];
var x = this.heap[--size];
var i = 0;
while ((i << 1) + 1 < size) {
var a = (i << 1) + 1;
var b = (i << 1) + 2;
if (b < size && compare(heap[b], heap[a]) < 0)
a = b;
if (compare(heap[a], x) >= 0)
break;
heap[i] = heap[a];
i = a;
}
heap[i] = x;
heap.RemoveAt(size);
return ret;
}
public T Peek() { return heap[0]; }
public int Count {
get { return size; }
}
public bool Any() { return size > 0; }
}
public class Math2 {
public long[] Fact; // Nまでの階乗
public long[] invFact; //階乗の逆元
// Nまでの階乗をセットしておく
public void FactoricalModSet(long N, long MOD = 1000000007) {
Fact = new long[N + 1];
invFact = new long[N + 1];
Fact[0] = 1;
for (long i = 1; i <= N; ++i) {
Fact[i] = Fact[i - 1] * i % MOD;
}
invFact[N] = pow(Fact[N], MOD - 2);
for (long i = N; i > 0; --i) {
invFact[i - 1] = invFact[i] * i % MOD;
}
}
// nCr 引数:n r (mod)
public long nCr(long n, long r, long MOD = 1000000007) {
return (Fact[n] * invFact[r] % MOD * invFact[n - r] % MOD);
}
//階乗(O(logN)) 引数:底x n乗 (MOD)
public long pow(long x, long n, long MOD = 1000000007) {
long res = 1;
while (n > 0) {
if ((n & 1) != 0)
res = res * x % MOD;
x = x * x % MOD;
n >>= 1;
}
return res;
}
//最大公約数 引数:整数x,y
public long GCD(long x, long y) {
while (y != 0) {
var r = x % y;
x = y;
y = r;
}
return x;
}
//最小公倍数 引数:整数x,y
public long LCM(long x, long y) { return x * y / GCD(x, y); }
//素因数分解 引数:整数N
public Dictionary<long, int> PrimeFactorization(long N) {
var ret = new Dictionary<long, int>();
for (long i = 2; i * i <= N; ++i) {
int cnt = 0;
while (N % i == 0) {
cnt++;
N /= i;
}
if (cnt != 0)
ret[i] = cnt;
}
if (N >= 2)
ret[N] = 1;
return ret;
}
public List<long> PrimeFactorization2(long N) {
var ret = new List<long>();
for (long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
ret.Add(i);
ret.Add(N / i);
}
}
return ret;
}
}
namespace CompLib.Algorithms {
#region BinarySearch
public static partial class Algorithm {
static int binarySearch<T>(IList<T> a, T v, IComparer<T> cmp, bool islb) {
var l = 0;
var r = a.Count - 1;
while (l <= r) {
var m = (l + r) / 2;
var res = cmp.Compare(a[m], v);
if (res < 0 || (res == 0 && !islb))
l = m + 1;
else
r = m - 1;
}
return l;
}
/// <summary>
/// 与えられた比較関数に従って,<paramref name="a"/> の要素のうち,<paramref
/// name="v"/> 以上の要素であるような最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int LowerBound<T>(this IList<T> a, T v, Comparison<T> f) {
return binarySearch(a, v, Comparer<T>.Create(f), true);
}
/// <summary>
/// デフォルトの比較関数に従って,<paramref name="a"/>
///の要素のうち,<paramref name="v"/>
///以上の要素であるような最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int LowerBound<T>(this IList<T> a, T v) {
return binarySearch(a, v, Comparer<T>.Default, true);
}
/// <summary>
/// 与えられた比較関数に従って,<paramref name="a"/> の要素のうち,<paramref
/// name="v"/> 以上の要素であるような最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int UpperBound<T>(this IList<T> a, T v, Comparison<T> cmp) {
return binarySearch(a, v, Comparer<T>.Create(cmp), false);
}
/// <summary>
/// デフォルトの比較関数に従って,<paramref name="a"/>
///の要素のうち,<paramref name="v"/>
///より真に大きい要素が現れる最小のインデックスを取得します.
/// </summary>
/// <typeparam name="T"><see cref="IList{T}"/>
/// の要素の型を指定します.</typeparam> <param
/// name="a">対象となるコレクション</param> <param
/// name="v">対象となる要素</param> <param name="f"></param>
/// <returns><paramref name="v"/> 以上の要素であるような最小の o-indexed
/// でのインデックス.</returns> <remarks> <paramref name="a"/>
/// は比較関数に対して昇順であることを仮定しています.この関数は O(log N)
/// で実行されます.</remarks>
public static int UpperBound<T>(this IList<T> a, T v) {
return binarySearch(a, v, Comparer<T>.Default, false);
}
}
#endregion
}
class Scaner {
public string Str => Console.ReadLine();
public string[] StrM => Str.Split(' ');
public long[] LongM => StrM.Select(long.Parse).ToArray();
public int[] IntM => StrM.Select(int.Parse).ToArray();
public char[] CharM => Str.ToArray();
public long Long1 => LongM[0];
public int Int1 => IntM[0];
}
class write {
public void wri<T>(T x) { Console.WriteLine(x); }
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["+", 0, 198, 0, 200, 0, 212, 0, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 12, 22]]
| 8
| 1,710
| 8
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
var N = cin.ReadLong;
var K = cin.ReadLong;
if (K % 2 == 1) {
var tmp = N / K;
WriteLine(tmp * tmp * tmp);
} else {
var tmp = N / K;
var tmp2 = 0;
for (var i = 1; i <= N; i++) {
if (i % K == K / 2)
tmp2++;
}
WriteLine(tmp * tmp * tmp + tmp2 * tmp2 * tmp2);
}
}
static long GcdArray(long[] array) {
var ans = array[0];
for (var i = 1; i < array.Length; i++) {
ans = Gcd(ans, array[i]);
}
return ans;
}
static long Gcd(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
// From
// http://visualstudiomagazine.com/articles/2012/11/01/priority-queues-with-c.aspx
public class PriorityQueue<T>
where T : IComparable<T> {
private List<T> data;
public PriorityQueue() { this.data = new List<T>(); }
public void Enqueue(T item) {
data.Add(item);
int ci = data.Count - 1; // child index; start at end
while (ci > 0) {
int pi = (ci - 1) / 2; // parent index
if (data[ci].CompareTo(data[pi]) >= 0)
break; // child item is larger than (or equal) parent so we're done
T tmp = data[ci];
data[ci] = data[pi];
data[pi] = tmp;
ci = pi;
}
}
public T Dequeue() {
// assumes pq is not empty; up to calling code
int li = data.Count - 1; // last index (before removal)
T frontItem = data[0]; // fetch the front
data[0] = data[li];
data.RemoveAt(li);
--li; // last index (after removal)
int pi = 0; // parent index. start at front of pq
while (true) {
int ci = pi * 2 + 1; // left child index of parent
if (ci > li)
break; // no children so done
int rc = ci + 1; // right child
if (rc <= li && data[rc].CompareTo(data[ci]) <
0) // if there is a rc (ci + 1), and it is smaller
// than left child, use the rc instead
ci = rc;
if (data[pi].CompareTo(data[ci]) <= 0)
break; // parent is smaller than (or equal to) smallest child so done
T tmp = data[pi];
data[pi] = data[ci];
data[ci] = tmp; // swap parent and child
pi = ci;
}
return frontItem;
}
public T Peek() {
T frontItem = data[0];
return frontItem;
}
public int Count() { return data.Count; }
public override string ToString() {
string s = "";
for (int i = 0; i < data.Count; ++i)
s += data[i].ToString() + " ";
s += "count = " + data.Count;
return s;
}
public bool IsConsistent() {
// is the heap property true for all data?
if (data.Count == 0)
return true;
int li = data.Count - 1; // last index
for (int pi = 0; pi < data.Count; ++pi) { // each parent index
int lci = 2 * pi + 1; // left child index
int rci = 2 * pi + 2; // right child index
if (lci <= li && data[pi].CompareTo(data[lci]) > 0)
return false; // if lc exists and it's greater than parent then bad.
if (rci <= li && data[pi].CompareTo(data[rci]) > 0)
return false; // check the right child too.
}
return true; // passed all checks
}
// IsConsistent
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
namespace AtCoder {
public class Program {
public static void Main(string[] args) {
new Program().Solve(new ConsoleInput(Console.In, ' '));
}
public void Solve(ConsoleInput cin) {
long N = cin.ReadLong;
long K = cin.ReadLong;
if (K % 2 == 1) {
long tmp = N / K;
WriteLine(tmp * tmp * tmp);
} else {
long tmp = N / K;
long tmp2 = 0;
for (long i = 1; i <= N; i++) {
if (i % K == K / 2)
tmp2++;
}
WriteLine(tmp * tmp * tmp + tmp2 * tmp2 * tmp2);
}
}
static long GcdArray(long[] array) {
var ans = array[0];
for (var i = 1; i < array.Length; i++) {
ans = Gcd(ans, array[i]);
}
return ans;
}
static long Gcd(long a, long b) {
var v = new[] { a, b };
while (v[1] != 0) {
v = new[] { v[1], v[0] % v[1] };
}
return v[0];
}
static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
}
public class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
// From
// http://visualstudiomagazine.com/articles/2012/11/01/priority-queues-with-c.aspx
public class PriorityQueue<T>
where T : IComparable<T> {
private List<T> data;
public PriorityQueue() { this.data = new List<T>(); }
public void Enqueue(T item) {
data.Add(item);
int ci = data.Count - 1; // child index; start at end
while (ci > 0) {
int pi = (ci - 1) / 2; // parent index
if (data[ci].CompareTo(data[pi]) >= 0)
break; // child item is larger than (or equal) parent so we're done
T tmp = data[ci];
data[ci] = data[pi];
data[pi] = tmp;
ci = pi;
}
}
public T Dequeue() {
// assumes pq is not empty; up to calling code
int li = data.Count - 1; // last index (before removal)
T frontItem = data[0]; // fetch the front
data[0] = data[li];
data.RemoveAt(li);
--li; // last index (after removal)
int pi = 0; // parent index. start at front of pq
while (true) {
int ci = pi * 2 + 1; // left child index of parent
if (ci > li)
break; // no children so done
int rc = ci + 1; // right child
if (rc <= li && data[rc].CompareTo(data[ci]) <
0) // if there is a rc (ci + 1), and it is smaller
// than left child, use the rc instead
ci = rc;
if (data[pi].CompareTo(data[ci]) <= 0)
break; // parent is smaller than (or equal to) smallest child so done
T tmp = data[pi];
data[pi] = data[ci];
data[ci] = tmp; // swap parent and child
pi = ci;
}
return frontItem;
}
public T Peek() {
T frontItem = data[0];
return frontItem;
}
public int Count() { return data.Count; }
public override string ToString() {
string s = "";
for (int i = 0; i < data.Count; ++i)
s += data[i].ToString() + " ";
s += "count = " + data.Count;
return s;
}
public bool IsConsistent() {
// is the heap property true for all data?
if (data.Count == 0)
return true;
int li = data.Count - 1; // last index
for (int pi = 0; pi < data.Count; ++pi) { // each parent index
int lci = 2 * pi + 1; // left child index
int rci = 2 * pi + 2; // right child index
if (lci <= li && data[pi].CompareTo(data[lci]) > 0)
return false; // if lc exists and it's greater than parent then bad.
if (rci <= li && data[pi].CompareTo(data[rci]) > 0)
return false; // check the right child too.
}
return true; // passed all checks
}
// IsConsistent
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 64, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["-", 75, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["-", 75, 196, 0, 7, 10, 198, 39, 216, 0, 217], ["+", 0, 57, 75, 196, 0, 7, 10, 198, 39, 199]]
| 8
| 1,177
| 12
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Procon {
static void Main(string[] agrs) {
long N = Long();
long K = Long();
long tmp1 = N / K;
long tmp2 = 0;
if (K % 2 == 0) {
tmp2 = (N - K / 2) / K + 1;
}
Dbg(tmp1 * tmp1 * tmp1 + tmp2 * tmp2 * tmp2);
}
static string String() => Scanner.nextString();
static int Int() => int.Parse(Scanner.nextString());
static long Long() => long.Parse(Scanner.nextString());
static double Double() => double.Parse(Scanner.nextString());
static char[] Chars() => String().ToCharArray();
static string[] Strings() => Console.ReadLine().Split(' ');
static int[] Ints() => Strings().Select(v => int.Parse(v)).ToArray();
static long[] Longs() => Strings().Select(v => long.Parse(v)).ToArray();
static double[] Doubles() => Strings().Select(v => double.Parse(v)).ToArray();
const int M = 1000000007;
static void Dbg(object a) => Console.WriteLine(a);
static void Dbg(params object[] a) => Console.WriteLine(string.Join(" ", a));
static void Dbgs<T>(IEnumerable<T> a, string split = " ") =>
Console.WriteLine(string.Join(split, a));
static T Max<T>(params T[] a) => a.Max();
static T Min<T>(params T[] a) => a.Min();
}
class PriorityQueue<T>
where T : IComparable<T> {
public T[] heap;
public int size;
public int sign;
public PriorityQueue(int N, bool descend = false) {
heap = new T[N];
if (descend)
sign = -1;
}
public int Compare(T x, T y) { return x.CompareTo(y) * sign; }
public void Push(T x) {
int i = size++;
while (i > 0) {
int p = (i - 1) / 2;
if (Compare(x, heap[p]) >= 0) {
break;
}
heap[i] = heap[p];
i = p;
}
heap[i] = x;
}
public T Pop() {
T ret = heap[0];
T x = heap[--size];
int i = 0;
while (i * 2 + 1 < size) {
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < size && Compare(heap[a], heap[b]) > 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 size; }
}
class Scanner {
static string[] s = new string[0];
static int i = 0;
static int max_i = 0;
static public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
}
return s[i++];
}
}
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Procon {
static void Main(string[] agrs) {
long N = Long();
long K = Long();
long tmp1 = N / K;
long tmp2 = 0;
if (K % 2 == 0 && N >= K / 2) {
tmp2 = (N - K / 2) / K + 1;
}
Dbg(tmp1 * tmp1 * tmp1 + tmp2 * tmp2 * tmp2);
}
static string String() => Scanner.nextString();
static int Int() => int.Parse(Scanner.nextString());
static long Long() => long.Parse(Scanner.nextString());
static double Double() => double.Parse(Scanner.nextString());
static char[] Chars() => String().ToCharArray();
static string[] Strings() => Console.ReadLine().Split(' ');
static int[] Ints() => Strings().Select(v => int.Parse(v)).ToArray();
static long[] Longs() => Strings().Select(v => long.Parse(v)).ToArray();
static double[] Doubles() => Strings().Select(v => double.Parse(v)).ToArray();
const int M = 1000000007;
static void Dbg(object a) => Console.WriteLine(a);
static void Dbg(params object[] a) => Console.WriteLine(string.Join(" ", a));
static void Dbgs<T>(IEnumerable<T> a, string split = " ") =>
Console.WriteLine(string.Join(split, a));
static T Max<T>(params T[] a) => a.Max();
static T Min<T>(params T[] a) => a.Min();
}
class PriorityQueue<T>
where T : IComparable<T> {
public T[] heap;
public int size;
public int sign;
public PriorityQueue(int N, bool descend = false) {
heap = new T[N];
if (descend)
sign = -1;
}
public int Compare(T x, T y) { return x.CompareTo(y) * sign; }
public void Push(T x) {
int i = size++;
while (i > 0) {
int p = (i - 1) / 2;
if (Compare(x, heap[p]) >= 0) {
break;
}
heap[i] = heap[p];
i = p;
}
heap[i] = x;
}
public T Pop() {
T ret = heap[0];
T x = heap[--size];
int i = 0;
while (i * 2 + 1 < size) {
int a = i * 2 + 1;
int b = i * 2 + 2;
if (b < size && Compare(heap[a], heap[b]) > 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 size; }
}
class Scanner {
static string[] s = new string[0];
static int i = 0;
static int max_i = 0;
static public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
}
return s[i++];
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 17, 85], ["+", 0, 57, 15, 16, 12, 16, 12, 16, 12, 203]]
| 8
| 812
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
// var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int K = input[1];
long ans = 0;
int Kn = N / K;
ans += Kn * Kn * Kn;
if (K % 2 == 0) {
int modK = 0;
for (var i = 1; i <= N; i++) {
if (i % K == K / 2) {
modK++;
}
}
ans += modK * modK * modK;
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
public class Calculation {}
public class Graph {}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
// var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve {
class Solve {
const int mod = 1000000007;
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
long N = input[0];
long K = input[1];
long ans = 0;
long Kn = N / K;
ans += Kn * Kn * Kn;
if (K % 2 == 0) {
long modK = 0;
for (var i = 1; i <= N; i++) {
if (i % K == K / 2) {
modK++;
}
}
ans += modK * modK * modK;
}
Console.WriteLine(ans);
Console.Out.Flush();
}
}
public class Calculation {}
public class Graph {}
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["+", 205, 213, 3, 4, 0, 28, 0, 214, 205, 199], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 215
| 10
|
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 void chmin<T>(ref T num, T val) where T : IComparable<T>
=> num = num.CompareTo(val) == 1 ? val : num;
private static void chmax<T>(ref T num, T val) where T : IComparable<T>
=> num = num.CompareTo(val) == -1 ? val : num;
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();
}
void Solve()
{
int num, k;
Input.Make(out num, out k);
var ct1 = 0;
var ct2 = 0;
for(var i = 1; i <= num; i++)
{
if (i % k == 0) ct1++;
if (k % 2 == 0 && i % k == k / 2) ct2++;
}
WriteLine(ct1 * ct1 * ct1 + ct2 * ct2 * ct2);
}
}
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[][] gred(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;
}
|
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 void chmin<T>(ref T num, T val) where T : IComparable<T>
=> num = num.CompareTo(val) == 1 ? val : num;
private static void chmax<T>(ref T num, T val) where T : IComparable<T>
=> num = num.CompareTo(val) == -1 ? val : num;
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();
}
void Solve()
{
int num, k;
Input.Make(out num, out k);
var ct1 = 0L;
var ct2 = 0L;
for(var i = 1; i <= num; i++)
{
if (i % k == 0) ct1++;
if (k % 2 == 0 && i % k == k / 2) ct2++;
}
WriteLine(ct1 * ct1 * ct1 + ct2 * ct2 * ct2);
}
}
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[][] gred(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;
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 1,126
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
class Program {
static void Main(string[] args) {
var nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var mod0 = 0;
var modk = 0;
for (var i = 1; i <= nk[0]; i++) {
if (i % nk[1] == 0)
mod0++;
if (i % nk[1] == nk[1] / 2)
modk++;
}
if (nk[1] % 2 != 0)
WriteLine((long)Pow(mod0, 3));
else
WriteLine((long)Pow(mod0, 3) + Pow(modk, 3));
}
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;
class Program {
static void Main(string[] args) {
var nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
var mod0 = 0;
var modk = 0;
for (var i = 1; i <= nk[0]; i++) {
if (i % nk[1] == 0)
mod0++;
if (i % nk[1] == nk[1] / 2)
modk++;
}
if (nk[1] % 2 != 0)
WriteLine((long)Pow(mod0, 3));
else
WriteLine((long)Pow(mod0, 3) + (long)Pow(modk, 3));
}
private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
private const int MOD = 1000000007;
}
|
[["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 24], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 39, 199], ["+", 3, 4, 0, 28, 0, 16, 12, 74, 0, 25]]
| 8
| 194
| 3
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var inputs = Console.ReadLine().Split(' ');
var N = int.Parse(inputs[0]);
var K = int.Parse(inputs[1]);
var kCount = 0;
var halfKCount = 0;
for (int i = 1; i <= N; i++) {
if (i % K == 0) {
kCount++;
}
if (K % 2 == 0 && i % K == K / 2) {
halfKCount++;
}
}
var ans = 0;
if (K % 2 == 0) {
ans = pow(kCount, 3) + pow(halfKCount, 3);
} else {
ans = pow(kCount, 3);
}
Console.WriteLine(ans);
}
static int pow(int baseValue, int n) {
var ans = 1;
for (int i = 1; i <= n; i++) {
ans *= baseValue;
}
return ans;
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
var inputs = Console.ReadLine().Split(' ');
var N = int.Parse(inputs[0]);
var K = int.Parse(inputs[1]);
var kCount = 0;
var halfKCount = 0;
for (int i = 1; i <= N; i++) {
if (i % K == 0) {
kCount++;
}
if (K % 2 == 0 && i % K == K / 2) {
halfKCount++;
}
}
var ans = 0L;
if (K % 2 == 0) {
ans = pow(kCount, 3) + pow(halfKCount, 3);
} else {
ans = pow(kCount, 3);
}
Console.WriteLine(ans);
}
static long pow(long baseValue, long n) {
var ans = 1L;
for (long i = 1; i <= n; i++) {
ans *= baseValue;
}
return ans;
}
}
|
[["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["-", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["+", 8, 201, 0, 195, 54, 55, 0, 220, 39, 199], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199]]
| 8
| 222
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace AtCoder {
class Program {
static void Main() {
//ここから
int[] str = IO.ReadLineToIntArray();
int N = str[0];
int K = str[1];
long ans = 0;
if (N < 2 * K) {
Console.WriteLine(0);
return;
}
if (K % 2 == 0) {
ans += (long)Math.Pow((N - K / 2) / K + 1, 3);
}
ans += (long)Math.Pow(N / K, 3);
//ここまで
Console.WriteLine(ans);
Console.ReadKey();
}
}
class Func {
long mod = 1000000007;
static public void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
static public int Factorial(int a) {
return a == 1 ? a : a * Factorial(a - 1);
}
static public int Conbin(int n, int m) {
return Factorial(n) / (Factorial(n - m) * Factorial(m));
}
static public void Factoring(long num, ref long[] vs) {
if (num == 1) {
vs[1]++;
}
for (long i = 2; i < (long)Math.Sqrt(num); i++) {
if (num % i == 0) {
vs[i]++;
Factoring(num / i, ref vs);
}
}
vs[1]++;
}
}
class IO {
static public string ReadLineToString() { return Console.ReadLine(); }
static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
static public string[] ReadLineToStringArray() {
return Console.ReadLine().Split(' ').ToArray();
}
static public int[] ReadLineToIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] ReadLineToLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<string> ReadLineToStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> ReadLineToIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> ReadLineToLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace AtCoder {
class Program {
static void Main() {
//ここから
int[] str = IO.ReadLineToIntArray();
int N = str[0];
int K = str[1];
long ans = 0;
if (2 * N < K) {
Console.WriteLine(0);
return;
}
if (K % 2 == 0) {
ans += (long)Math.Pow((N - K / 2) / K + 1, 3);
}
ans += (long)Math.Pow(N / K, 3);
//ここまで
Console.WriteLine(ans);
Console.ReadKey();
}
}
class Func {
long mod = 1000000007;
static public void Swap<T>(ref T a, ref T b) {
T temp = a;
a = b;
b = temp;
}
static public long GCD(int a, int b) { return b != 0 ? GCD(b, a % b) : a; }
static public long LCM(int a, int b) { return (long)a * b / GCD(a, b); }
static public int Factorial(int a) {
return a == 1 ? a : a * Factorial(a - 1);
}
static public int Conbin(int n, int m) {
return Factorial(n) / (Factorial(n - m) * Factorial(m));
}
static public void Factoring(long num, ref long[] vs) {
if (num == 1) {
vs[1]++;
}
for (long i = 2; i < (long)Math.Sqrt(num); i++) {
if (num % i == 0) {
vs[i]++;
Factoring(num / i, ref vs);
}
}
vs[1]++;
}
}
class IO {
static public string ReadLineToString() { return Console.ReadLine(); }
static public int ReadLineToInt() { return int.Parse(Console.ReadLine()); }
static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
static public string[] ReadLineToStringArray() {
return Console.ReadLine().Split(' ').ToArray();
}
static public int[] ReadLineToIntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
static public long[] ReadLineToLongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
static public List<string> ReadLineToStringList() {
return Console.ReadLine().Split(' ').ToList();
}
static public List<int> ReadLineToIntList() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
}
static public List<long> ReadLineToLongList() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18]]
| 8
| 663
| 4
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.IO;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
new Program().Solve(new ConsoleInput(Console.In, ' '));
Console.Out.Flush();
#if DEBUG
ReadLine();
#endif
}
void Solve(ConsoleInput cin) {
int n = cin.ReadInt;
int k = cin.ReadInt;
int k_div2 = k / 2;
int[] count = new int[] { 0, 0 };
for (int i = 1; i <= n; i++) {
if (i % k == 0)
count[0]++;
if (i % k == k_div2)
count[1]++;
}
long ans = k % 2 == 0 ? count[0] * count[0] * count[0] +
count[1] * count[1] * count[1]
: count[0] * count[0] * count[0];
Console.WriteLine(ans);
}
class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.IO;
namespace AtCoder {
class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
new Program().Solve(new ConsoleInput(Console.In, ' '));
Console.Out.Flush();
#if DEBUG
ReadLine();
#endif
}
void Solve(ConsoleInput cin) {
int n = cin.ReadInt;
int k = cin.ReadInt;
int k_div2 = k / 2;
long[] count = new long[] { 0, 0 };
for (int i = 1; i <= n; i++) {
if (i % k == 0)
count[0]++;
if (i % k == k_div2)
count[1]++;
}
long ans = k % 2 == 0 ? count[0] * count[0] * count[0] +
count[1] * count[1] * count[1]
: count[0] * count[0] * count[0];
Console.WriteLine(ans);
}
class ConsoleInput {
private readonly System.IO.TextReader _stream;
private char _separator = ' ';
private Queue<string> inputStream;
public ConsoleInput(System.IO.TextReader stream, char separator = ' ') {
this._separator = separator;
this._stream = stream;
inputStream = new Queue<string>();
}
public string Read {
get {
if (inputStream.Count != 0)
return inputStream.Dequeue();
string[] tmp = _stream.ReadLine().Split(_separator);
for (int i = 0; i < tmp.Length; ++i)
inputStream.Enqueue(tmp[i]);
return inputStream.Dequeue();
}
}
public string ReadLine {
get { return _stream.ReadLine(); }
}
public int ReadInt {
get { return int.Parse(Read); }
}
public long ReadLong {
get { return long.Parse(Read); }
}
public double ReadDouble {
get { return double.Parse(Read); }
}
public string[] ReadStrArray(long N) {
var ret = new string[N];
for (long i = 0; i < N; ++i)
ret[i] = Read;
return ret;
}
public int[] ReadIntArray(long N) {
var ret = new int[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadInt;
return ret;
}
public long[] ReadLongArray(long N) {
var ret = new long[N];
for (long i = 0; i < N; ++i)
ret[i] = ReadLong;
return ret;
}
}
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["+", 8, 196, 0, 197, 0, 198, 39, 224, 39, 199], ["-", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199], ["+", 0, 200, 0, 212, 0, 227, 39, 224, 39, 199]]
| 8
| 608
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
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 Int() { 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] = Int() + add;
}
return Array;
}
public long Long() { 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] = Long() + add;
}
return Array;
}
}
class Program {
static Scanner cin = new Scanner();
static void Main() {
int N = cin.Int();
int K = cin.Int();
if (K % 2 != 0) {
Console.WriteLine((N / K) * (N / K) * (N / K));
} else {
int num = N / (K / 2) - N / K;
Console.WriteLine((N / K) * (N / K) * (N / K) + num * num * num);
}
Console.ReadLine();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
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 Int() { 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] = Int() + add;
}
return Array;
}
public long Long() { 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] = Long() + add;
}
return Array;
}
}
class Program {
static Scanner cin = new Scanner();
static void Main() {
long N = cin.Long();
long K = cin.Long();
if (K % 2 != 0) {
Console.WriteLine((N / K) * (N / K) * (N / K));
} else {
long num = N / (K / 2) - N / K;
Console.WriteLine((N / K) * (N / K) * (N / K) + num * num * num);
}
Console.ReadLine();
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 75, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 415
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C044 {
class C108 {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int N = int.Parse(s[0]);
int K = int.Parse(s[1]);
int num = N / K;
long counter = (long)num * num * num;
if (K % 2 == 0) {
int num2 = (N + K / 2) / K;
counter += num2 * num2 * num2;
}
Console.WriteLine(counter);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace C044 {
class C108 {
static void Main(string[] args) {
string[] s = Console.ReadLine().Split(' ');
int N = int.Parse(s[0]);
int K = int.Parse(s[1]);
int num = N / K;
long counter = (long)num * num * num;
if (K % 2 == 0) {
int num2 = (N + K / 2) / K;
counter += (long)num2 * num2 * num2;
}
Console.WriteLine(counter);
}
}
}
|
[["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 24], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 39, 199], ["+", 0, 11, 12, 16, 31, 16, 31, 74, 0, 25]]
| 8
| 147
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC108C {
static class MainClass {
public static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
int N = int.Parse(input1[0]);
int K = int.Parse(input1[1]);
long cnt = 0;
long ans = 0;
long cntk2 = 0;
long cntk0 = 0;
if (K % 2 == 1) {
cnt = N / K;
ans = cnt * cnt * cnt;
} else {
//あまりがK/2のもののペア
cntk2 = (int)Math.Pow((N + (K / 2)) / K, 3);
//あまりが0のもののペア
cntk0 = (int)Math.Pow(N / K, 3);
ans = cntk2 + cntk0;
}
Console.WriteLine(ans);
return;
}
public static int Gcd(int a, int b) {
int 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);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace ABC108C {
static class MainClass {
public static void Main(string[] args) {
string[] input1 = Console.ReadLine().Split(' ');
int N = int.Parse(input1[0]);
int K = int.Parse(input1[1]);
long cnt = 0;
long ans = 0;
long cntk2 = 0;
long cntk0 = 0;
if (K % 2 == 1) {
cnt = N / K;
ans = cnt * cnt * cnt;
} else {
//あまりがK/2のもののペア
cntk2 = (long)Math.Pow((N + (K / 2)) / K, 3);
//あまりが0のもののペア
cntk0 = (long)Math.Pow(N / K, 3);
ans = cntk2 + cntk0;
}
Console.WriteLine(ans);
return;
}
public static int Gcd(int a, int b) {
int 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);
}
}
}
|
[["-", 75, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 75, 196, 0, 1, 0, 11, 12, 74, 39, 199]]
| 8
| 254
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
string[] s = Console.ReadLine().Split().ToArray();
int n = int.Parse(s[0]);
int k = int.Parse(s[1]);
long ans = 0;
if (k % 2 == 1) {
int tmp = 0;
for (int i = 1; i <= n; i++) {
if (i % k == 0)
tmp++;
}
ans = tmp * tmp * tmp;
} else {
long tmp = 0;
long tmp2 = 0;
for (int i = 1; i <= n; i++) {
if (i % k == 0)
tmp++;
else if (i % k == k / 2)
tmp2++;
}
ans = tmp * tmp * tmp + tmp2 * tmp2 * tmp2;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main() {
string[] s = Console.ReadLine().Split().ToArray();
int n = int.Parse(s[0]);
int k = int.Parse(s[1]);
long ans = 0;
if (k % 2 == 1) {
long tmp = 0;
for (int i = 1; i <= n; i++) {
if (i % k == 0)
tmp++;
}
ans = tmp * tmp * tmp;
} else {
long tmp = 0;
long tmp2 = 0;
for (int i = 1; i <= n; i++) {
if (i % k == 0)
tmp++;
else if (i % k == k / 2)
tmp2++;
}
ans = tmp * tmp * tmp + tmp2 * tmp2 * tmp2;
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 201
| 2
|
using System;
using System.Collections.Generic;
namespace AtCoder {
public class Program {
// ABC108-C ng
static void Main(string[] args) {
string[] sv = Console.ReadLine().Split();
int N = int.Parse(sv[0]);
int K = int.Parse(sv[1]);
int c1 = 0, c2 = 0;
for (int i = 1; i <= N; i++) {
if (i % K == 0) {
c1++;
// System.Diagnostics.Debug.WriteLine(i);
} else if (K % 2 == 0 && i % K == K / 2) {
c2++;
// System.Diagnostics.Debug.WriteLine(i);
}
}
Console.WriteLine(c1 * c1 * c1 + c2 * c2 * c2);
}
}
}
|
using System;
using System.Collections.Generic;
namespace AtCoder {
public class Program {
// ABC108-C ng
static void Main(string[] args) {
string[] sv = Console.ReadLine().Split();
int N = int.Parse(sv[0]);
int K = int.Parse(sv[1]);
long c1 = 0, c2 = 0;
for (int i = 1; i <= N; i++) {
if (i % K == 0) {
c1++;
// System.Diagnostics.Debug.WriteLine(i);
} else if (K % 2 == 0 && i % K == K / 2) {
c2++;
// System.Diagnostics.Debug.WriteLine(i);
}
}
Console.WriteLine(c1 * c1 * c1 + c2 * c2 * c2);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 151
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC108.C {
class Program {
static void Main() {
var sc = new Scanner();
var n = sc.Nextint();
var k = sc.Nextint();
var count = 0d;
if (k % 2 == 0) {
var multiples = n / k;
count += Math.Pow(multiples, 3);
var halfk = k / 2;
var halfkCount = 0;
while (halfk <= n) {
halfkCount++;
halfk += k;
}
count += Math.Pow(halfkCount, 3);
Console.WriteLine(count);
} else {
var multiples = n / k;
count += Math.Pow(multiples, 3);
Console.WriteLine(count);
}
}
}
class Scanner {
string[] s;
long i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int Nextint() { return int.Parse(Next()); }
public int[] Arrayint(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Nextint() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (long i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(long N, double add = 0) {
double[] Array = new double[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
public decimal NextDecimal() { return decimal.Parse(Next()); }
public decimal[] ArrayDecimal(long N, decimal add = 0) {
decimal[] Array = new decimal[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDecimal();
}
return Array;
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AtCoder.ABC108.C {
class Program {
static void Main() {
var sc = new Scanner();
var n = sc.Nextint();
var k = sc.Nextint();
var count = 0d;
if (k % 2 == 0) {
var multiples = n / k;
count += Math.Pow(multiples, 3);
var halfk = k / 2;
var halfkCount = 0;
while (halfk <= n) {
halfkCount++;
halfk += k;
}
count += Math.Pow(halfkCount, 3);
Console.WriteLine((long)count);
} else {
var multiples = n / k;
count += Math.Pow(multiples, 3);
Console.WriteLine((long)count);
}
}
}
class Scanner {
string[] s;
long i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string Next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return Next();
i = 0;
return s[i++];
}
public int Nextint() { return int.Parse(Next()); }
public int[] Arrayint(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = Nextint() + add;
}
return Array;
}
public long NextLong() { return long.Parse(Next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (long i = 0; i < N; i++) {
Array[i] = NextLong() + add;
}
return Array;
}
public double NextDouble() { return double.Parse(Next()); }
public double[] ArrayDouble(long N, double add = 0) {
double[] Array = new double[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDouble() + add;
}
return Array;
}
public decimal NextDecimal() { return decimal.Parse(Next()); }
public decimal[] ArrayDecimal(long N, decimal add = 0) {
decimal[] Array = new decimal[N];
for (long i = 0; i < N; i++) {
Array[i] = NextDecimal();
}
return Array;
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 74, 0, 24], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 39, 199], ["+", 0, 213, 3, 4, 0, 28, 0, 74, 0, 25], ["+", 75, 196, 0, 1, 0, 213, 3, 4, 0, 24]]
| 8
| 610
| 6
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
int k = int.Parse(str[1]);
int res = 0;
// Console.WriteLine("{0}, {1}", n, k);
if (k % 2 == 0) {
int kk = k / 2;
int knum = n / k;
int kknum = n / kk - knum;
res = powi(knum, 3) + powi(kknum, 3);
} else {
int knum = n / k;
res = powi(knum, 3);
}
Console.WriteLine("{0}", res);
}
static int powi(int x, int n) {
int res = 1;
for (int i = 0; i < n; i++) {
res *= x;
}
return res;
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
int k = int.Parse(str[1]);
ulong res = 0;
// Console.WriteLine("{0}, {1}", n, k);
if (k % 2 == 0) {
int kk = k / 2;
int knum = n / k;
int kknum = n / kk - knum;
res = powi(knum, 3) + powi(kknum, 3);
} else {
int knum = n / k;
res = powi(knum, 3);
}
Console.WriteLine("{0}", res);
}
static ulong powi(int x, int n) {
ulong res = 1;
for (int i = 0; i < n; i++) {
res *= (ulong)x;
}
return res;
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 0, 208, 0, 235, 8, 201, 0, 195, 39, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 0, 24], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25]]
| 8
| 187
| 9
|
using System;
namespace ABC108_C {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var n = long.Parse(input[0]);
var k = long.Parse(input[1]);
var ans = Math.Pow(n / k, 3);
var temp = 0;
if (k % 2 == 0) {
for (var i = 1; i <= n; i++) {
if (i % k == k / 2) {
temp++;
}
}
}
ans += Math.Pow(temp, 3);
Console.WriteLine(ans);
}
}
}
|
using System;
namespace ABC108_C {
class Program {
static void Main(string[] args) {
var input = Console.ReadLine().Split(' ');
var n = long.Parse(input[0]);
var k = long.Parse(input[1]);
var ans = (long)Math.Pow(n / k, 3);
var temp = 0;
if (k % 2 == 0) {
for (var i = 1; i <= n; i++) {
if (i % k == k / 2) {
temp++;
}
}
}
ans += (long)Math.Pow(temp, 3);
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 24], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 39, 199], ["+", 0, 198, 0, 200, 0, 212, 0, 74, 0, 25], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 0, 24], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 0, 25]]
| 8
| 142
| 6
|
using System;
using System.Linq;
using System.Collections.Generic;
using E = System.Linq.Enumerable;
public class Program {
public static void Main() {
var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
var n = nk[0];
var k = nk[1];
var m = n / k;
var l = (n + k / 2) / k;
var z = m * m * m + (-k % 2 + 1) * l * l * l;
Console.WriteLine(z);
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
using E = System.Linq.Enumerable;
public class Program {
public static void Main() {
var nk = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
var n = nk[0];
var k = nk[1];
long m = n / k;
long l = (n + k / 2) / k;
var z = m * m * m + (-k % 2 + 1) * l * l * l;
Console.WriteLine(z);
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 133
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
static void Main(string[] args) {
SolveA(args);
// SolveB(args);
// SolveC(args);
// SolveD(args);
}
static void SolveA(string[] args) {
int[] nk = ReadAndParseIntArr();
int n = nk[0];
int k = nk[1];
long cnt = 0;
if (k % 2 == 0) {
int tmp = k / 2;
int cntA = 0;
int cntB = 0;
for (int i = 1; i <= n; ++i) {
if (i % k == 0) {
cntA++;
}
if (i % k == tmp) {
cntB++;
}
}
cnt = cntA * cntA * cntA + cntB * cntB * cntB;
} else {
for (int i = 1; i <= n; ++i) {
if (i % k == 0) {
cnt++;
}
}
// cntの数の組み合わせ
cnt = cnt * cnt * cnt;
}
Console.WriteLine(cnt);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Practice {
class Program {
private static int ReadAndParseInt() { return int.Parse(Console.ReadLine()); }
private static int[] ReadAndParseIntArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
}
private static long ReadAndParseLong() {
return long.Parse(Console.ReadLine());
}
private static long[] ReadAndParseLongArr() {
return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
}
static void Main(string[] args) {
SolveA(args);
// SolveB(args);
// SolveC(args);
// SolveD(args);
}
static void SolveA(string[] args) {
int[] nk = ReadAndParseIntArr();
int n = nk[0];
int k = nk[1];
long cnt = 0;
if (k % 2 == 0) {
long tmp = k / 2;
long cntA = 0;
long cntB = 0;
for (int i = 1; i <= n; ++i) {
if (i % k == 0) {
cntA++;
}
if (i % k == tmp) {
cntB++;
}
}
cnt = cntA * cntA * cntA + cntB * cntB * cntB;
} else {
for (int i = 1; i <= n; ++i) {
if (i % k == 0) {
cnt++;
}
}
// cntの数の組み合わせ
cnt = cnt * cnt * cnt;
}
Console.WriteLine(cnt);
}
}
}
|
[["-", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 325
| 6
|
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;
class Program {
static Scanner sc = new Scanner();
internal static void Main(string[] args) {
var N = sc.nextInt();
var K = sc.nextInt();
var ans = 0;
var div = (double)N / K;
var hoge = Math.Floor(div);
ans += (int)(hoge * hoge * hoge);
if (K % 2 == 0) {
if (N % K >= K / 2) {
hoge++;
}
ans += (int)(hoge * hoge * hoge);
}
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.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;
class Program {
static Scanner sc = new Scanner();
internal static void Main(string[] args) {
var N = sc.nextInt();
var K = sc.nextInt();
long ans = 0;
var div = (double)N / K;
var hoge = Math.Floor(div);
ans += (long)(hoge * hoge * hoge);
if (K % 2 == 0) {
if (N % K >= K / 2) {
hoge++;
}
ans += (long)(hoge * hoge * hoge);
}
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;
}
}
|
[["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 8, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["-", 64, 196, 0, 1, 0, 11, 12, 74, 39, 199], ["+", 64, 196, 0, 1, 0, 11, 12, 74, 39, 199]]
| 8
| 500
| 6
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
long[] inpt =
Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
long max = inpt[0];
long div = inpt[1];
long cnt = max / div;
long ans = cnt * cnt * cnt;
if (div % 2 == 0) {
if (cnt * div + (div % 2) > max) {
cnt--;
}
cnt++;
ans += cnt * cnt * cnt;
}
Console.WriteLine(ans);
}
public class Reader {
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
35897 932
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
long[] inpt =
Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
long max = inpt[0];
long div = inpt[1];
long cnt = max / div;
long ans = cnt * cnt * cnt;
if (div % 2 == 0) {
if (cnt * div + (div / 2) > max) {
cnt--;
}
cnt++;
ans += cnt * cnt * cnt;
}
Console.WriteLine(ans);
}
public class Reader {
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
35897 932
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
[["-", 15, 16, 31, 16, 12, 23, 0, 16, 17, 109], ["+", 15, 16, 31, 16, 12, 23, 0, 16, 17, 85]]
| 8
| 261
| 2
|
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 NK = Sarray();
var N = NK[0];
var K = NK[1];
var ans = 0L;
ans = (N / K) * (N / K) * (N / K);
if (K % 2 == 0) {
var sel = (N - K / 2) / K + 1;
ans += sel * sel * sel;
}
WriteLine(ans);
// Out.Flush();
}
}
}
|
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 NK = Sarray();
var N = NK[0];
var K = NK[1];
var ans = 0L;
ans = (N / K) * (N / K) * (N / K);
if (K % 2 == 0 && K / 2 <= N) {
var sel = (N - K / 2) / K + 1;
ans += sel * sel * sel;
}
WriteLine(ans);
// Out.Flush();
}
}
}
|
[["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 216
| 6
|
using System;
using System.Linq;
namespace ARC102 {
class C {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int K = input[1];
long[] num = new long[N + 10];
for (int i = 1; i <= N; i++)
num[i % K]++;
long res = 0;
for (int a = 0; a < K; a++) {
int b = (K - a) % K;
int c = (K - a) % K;
if ((b + c) % K != 0)
continue;
res += num[a] * num[b] * num[c];
}
Console.WriteLine(res);
}
}
}
|
using System;
using System.Linq;
namespace ARC102 {
class C {
static void Main(string[] args) {
int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
int N = input[0];
int K = input[1];
long[] num = new long[K];
for (int i = 1; i <= N; i++)
num[i % K]++;
long res = 0;
for (int a = 0; a < K; a++) {
int b = (K - a) % K;
int c = (K - a) % K;
if ((b + c) % K != 0)
continue;
res += num[a] * num[b] * num[c];
}
Console.WriteLine(res);
}
}
}
|
[["-", 0, 227, 39, 224, 225, 226, 0, 16, 31, 22], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 17, 72], ["-", 0, 227, 39, 224, 225, 226, 0, 16, 12, 203], ["+", 0, 212, 0, 227, 39, 224, 225, 226, 0, 22]]
| 8
| 185
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;
class MyUtil {
public static int[] ReadIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
class Program {
public static void Main() {
var tmp = ReadIntArray();
int n = tmp[0], k = tmp[1];
int n0 = n / k;
int ans = n0 * n0 * n0;
if (k % 2 == 0) {
int n1 = (n0 * k + k / 2) <= n ? n0 + 1 : n0;
if (k / 2 <= n) {
ans += n1 * n1 * n1;
}
}
WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;
class MyUtil {
public static int[] ReadIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
class Program {
public static void Main() {
var tmp = ReadIntArray();
int n = tmp[0], k = tmp[1];
long n0 = n / k;
long ans = n0 * n0 * n0;
if (k % 2 == 0) {
long n1 = (n0 * k + k / 2) <= n ? n0 + 1 : n0;
if (k / 2 <= n) {
ans += n1 * n1 * n1;
}
}
WriteLine(ans);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 57, 64, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 168
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;
class MyUtil {
public static int[] ReadIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
class Program {
public static void Main() {
var tmp = ReadIntArray();
int n = tmp[0], k = tmp[1];
int n0 = 0;
for (int i = 1; i <= n; i++) {
if (i % k == 0) {
n0++;
}
}
int n1 = 0;
if (k % 2 == 0) {
for (int i = 1; i <= n; i++) {
if (i % k == k / 2) {
n1++;
}
}
}
int ans = n0 * n0 * n0 + n1 * n1 * n1;
WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;
class MyUtil {
public static int[] ReadIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
}
class Program {
public static void Main() {
var tmp = ReadIntArray();
int n = tmp[0], k = tmp[1];
long n0 = 0;
for (int i = 1; i <= n; i++) {
if (i % k == 0) {
n0++;
}
}
long n1 = 0;
if (k % 2 == 0) {
for (int i = 1; i <= n; i++) {
if (i % k == k / 2) {
n1++;
}
}
}
long ans = n0 * n0 * n0 + n1 * n1 * n1;
WriteLine(ans);
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 198
| 6
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]), k = int.Parse(input[1]);
long ans = 0;
for (int i = 1; i <= k; i++) {
if ((2 * i) % k == 0) {
ans += (long)((n - i) / k + 1) * ((n - i) / k + 1) * ((n - i) / k + 1);
}
}
Console.WriteLine(ans);
}
}
// mcs Main.cs
// mono Main.exe
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] input = Console.ReadLine().Split(' ');
int n = int.Parse(input[0]), k = int.Parse(input[1]);
long ans = 0;
for (int i = 1; i <= k; i++) {
if ((2 * i) % k == 0 && n >= i) {
// Console.Error.WriteLine(i);
ans += (long)((n - i) / k + 1) * ((n - i) / k + 1) * ((n - i) / k + 1);
}
}
Console.WriteLine(ans);
}
}
// mcs Main.cs
// mono Main.exe
|
[["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 17, 20], ["+", 8, 196, 0, 57, 15, 16, 12, 16, 12, 22]]
| 8
| 153
| 4
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
long N = long.Parse(str[0]);
long K = long.Parse(str[1]);
long ans = 0;
long a = N / K;
ans += a * a * a;
if (K % 2 == 0) {
a = (N - 1) / K + 1;
ans += a * a * a;
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split();
long N = long.Parse(str[0]);
long K = long.Parse(str[1]);
long ans = 0;
long a = N / K;
ans += a * a * a;
if (K % 2 == 0) {
a = (N + K / 2) / K;
ans += a * a * a;
}
Console.WriteLine(ans);
}
}
|
[["-", 12, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["-", 12, 16, 31, 16, 31, 23, 0, 16, 12, 203], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 31, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 17, 85], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 12, 203], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
| 8
| 123
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive {
internal class Solution {
public long N, K;
public void Run() {
{
var line = Input.ReadLongArray();
N = line[0];
K = line[1];
}
long ret = 0;
long C = N / K;
ret += C * C * C;
if (K % 2 == 0) {
long C2 = (N - K / 2) / K + 1;
ret += C2 * C2 * C2;
}
Console.WriteLine(ret);
}
}
// libs ----------
// common ----------
internal static class Input {
public static string ReadString() {
string line = Console.ReadLine();
return line;
}
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() {
string line = Console.ReadLine();
return long.Parse(line);
}
public static long[] ReadLongArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(double.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Competitive {
internal class Solution {
public long N, K;
public void Run() {
{
var line = Input.ReadLongArray();
N = line[0];
K = line[1];
}
long ret = 0;
long C = N / K;
ret += C * C * C;
if (K % 2 == 0) {
// 余りがK/2の個数
long C2 = (N + K / 2) / K;
ret += C2 * C2 * C2;
}
Console.WriteLine(ret);
}
}
// libs ----------
// common ----------
internal static class Input {
public static string ReadString() {
string line = Console.ReadLine();
return line;
}
public static int ReadInt() {
string line = Console.ReadLine();
return int.Parse(line);
}
public static int[] ReadIntArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(int.Parse).ToArray();
}
public static long ReadLong() {
string line = Console.ReadLine();
return long.Parse(line);
}
public static long[] ReadLongArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(long.Parse).ToArray();
}
public static double[] ReadDoubleArray() {
string line = Console.ReadLine();
return line.Split(' ').Select(double.Parse).ToArray();
}
}
internal class Program {
public static void Main(string[] args) {
var s = new Solution();
s.Run();
}
}
}
|
[["-", 0, 16, 31, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 72], ["-", 0, 198, 0, 200, 0, 212, 0, 16, 12, 203]]
| 8
| 356
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
public class Program {
public static void Main(string[] args) {
List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
Console.WriteLine(input[0] / input[1] == 0 ? "0" : " 1");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
public class Program {
public static void Main(string[] args) {
List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
Console.WriteLine(input[0] % input[1] == 0 ? "0" : " 1");
}
}
|
[["-", 0, 28, 0, 41, 15, 16, 31, 16, 17, 85], ["+", 0, 28, 0, 41, 15, 16, 31, 16, 17, 109]]
| 8
| 87
| 2
|
using System;
using static System.Console;
namespace AtCorder {
public class Program {
public static void Main() {
var input = Array.ConvertAll(ReadLine().Split(), int.Parse);
var n = input[0];
var k = input[1];
WriteLine(n % k);
}
}
}
|
using System;
using static System.Console;
namespace AtCorder {
public class Program {
public static void Main() {
var input = Array.ConvertAll(ReadLine().Split(), int.Parse);
var n = input[0];
var k = input[1];
WriteLine(n % k == 0 ? 0 : 1);
}
}
}
|
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 203]]
| 8
| 69
| 6
|
using System;
using System.Linq;
namespace ABC105.Task01 {
internal class Task01 {
public static void Main(string[] args) {
var line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var n = line[0];
var k = line[1];
var rest = n / k;
if (rest == 0) {
Console.WriteLine("1");
} else {
Console.WriteLine("0");
}
}
}
}
|
using System;
using System.Linq;
namespace ABC105.Task01 {
internal class Task01 {
public static void Main(string[] args) {
var line =
Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
var n = line[0];
var k = line[1];
var rest = n % k;
if (rest == 0) {
Console.WriteLine("0");
} else {
Console.WriteLine("1");
}
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 16, 17, 85], ["+", 0, 198, 0, 200, 0, 212, 0, 16, 17, 109], ["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 115
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static PB10004.Algorithm.Util;
namespace PB10004.Algorithm {
class Template {
static void Main(string[] args) { new A().Solve(); }
}
class A {
public void Solve() {
var array = ReadLongArray();
var N = array[0];
var K = array[0];
WriteLine(N % K == 0 ? 0 : 1);
}
}
class D {
public void Solve() {
var array = ReadLongArray();
var N = array[0];
var M = array[1];
var nums = ReadLongArray();
var cums = CumulativeSum(nums).ToArray();
long count = 0;
for (int i = 1; i < N + 1; i++) {
for (int j = i; j < N + 1; j++) {
if ((cums[j] - cums[i - 1]) % M == 0) {
count++;
}
}
}
WriteLine(count);
}
}
public static class Util {
/// <summary>
/// 標準入力をint型にパースする
/// </summary>
/// <returns></returns>
public static int ReadInt() { return int.Parse(ReadLine()); }
/// <summary>
/// 標準入力をint型の配列にする
/// </summary>
/// <returns></returns>
public static int[] ReadIntArray() {
return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// 標準入力をlong型にパースする
/// </summary>
/// <returns></returns>
public static long ReadLong() { return long.Parse(ReadLine()); }
/// <summary>
/// 標準入力をlong型の配列にする
/// </summary>
/// <returns></returns>
public static long[] ReadLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
/// <summary>
/// 一定値の数列を生成する
/// </summary>
/// <param name="value"></param>
/// <param name="length"></param>
/// <returns></returns>
public static IEnumerable<long> ConstSeq(long value, long length) {
for (int i = 0; i < length; i++) {
yield return value;
}
}
/// <summary>
/// int配列の累積和を求める
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) {
int tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// long配列の累積和を求める
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) {
long tmp = 0;
yield return tmp;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// 最大公約数をユークリッドの互除法で求める
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
return b == 0 ? a : Gcd(b, a % b);
}
/// <summary>
/// 最小公倍数を求める
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static PB10004.Algorithm.Util;
namespace PB10004.Algorithm {
class Template {
static void Main(string[] args) { new A().Solve(); }
}
class A {
public void Solve() {
var array = ReadLongArray();
var N = array[0];
var K = array[1];
WriteLine(N % K == 0 ? 0 : 1);
}
}
class D {
public void Solve() {
var array = ReadLongArray();
var N = array[0];
var M = array[1];
var nums = ReadLongArray();
var cums = CumulativeSum(nums).ToArray();
long count = 0;
for (int i = 1; i < N + 1; i++) {
for (int j = i; j < N + 1; j++) {
if ((cums[j] - cums[i - 1]) % M == 0) {
count++;
}
}
}
WriteLine(count);
}
}
public static class Util {
/// <summary>
/// 標準入力をint型にパースする
/// </summary>
/// <returns></returns>
public static int ReadInt() { return int.Parse(ReadLine()); }
/// <summary>
/// 標準入力をint型の配列にする
/// </summary>
/// <returns></returns>
public static int[] ReadIntArray() {
return ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
}
/// <summary>
/// 標準入力をlong型にパースする
/// </summary>
/// <returns></returns>
public static long ReadLong() { return long.Parse(ReadLine()); }
/// <summary>
/// 標準入力をlong型の配列にする
/// </summary>
/// <returns></returns>
public static long[] ReadLongArray() {
return ReadLine().Split(' ').Select(long.Parse).ToArray();
}
/// <summary>
/// 一定値の数列を生成する
/// </summary>
/// <param name="value"></param>
/// <param name="length"></param>
/// <returns></returns>
public static IEnumerable<long> ConstSeq(long value, long length) {
for (int i = 0; i < length; i++) {
yield return value;
}
}
/// <summary>
/// int配列の累積和を求める
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<int> CumulativeSum(IEnumerable<int> array) {
int tmp = 0;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// long配列の累積和を求める
/// </summary>
/// <param name="array"></param>
/// <returns></returns>
public static IEnumerable<long> CumulativeSum(IEnumerable<long> array) {
long tmp = 0;
yield return tmp;
foreach (var num in array)
yield return tmp += num;
}
/// <summary>
/// 最大公約数をユークリッドの互除法で求める
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Gcd(long a, long b) {
return b == 0 ? a : Gcd(b, a % b);
}
/// <summary>
/// 最小公倍数を求める
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static long Lcm(long a, long b) { return a * b / Gcd(a, b); }
}
}
|
[["-", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203], ["+", 0, 212, 0, 204, 206, 207, 0, 28, 0, 203]]
| 8
| 554
| 2
|
using System;
using System.Linq;
namespace ABC105_A {
class Program {
static void Main(string[] args) {
var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
var N = NK[0];
var K = NK[1];
Console.WriteLine(N % K);
}
}
}
|
using System;
using System.Linq;
namespace ABC105_A {
class Program {
static void Main(string[] args) {
var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
var N = NK[0];
var K = NK[1];
Console.WriteLine(N % K == 0 ? 0 : 1);
}
}
}
|
[["+", 3, 4, 0, 28, 0, 41, 15, 16, 17, 60], ["+", 3, 4, 0, 28, 0, 41, 15, 16, 12, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 64, 203], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 75, 203]]
| 8
| 76
| 6
|
using System;
namespace ABC105B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
Boolean buy = false;
for (int i = 0; i < (N / 4) + 1; i++) {
for (int j = 0; j < (N / 7) + 1; j++) {
if (4 * i + 7 + j == N)
buy = true;
}
}
if (buy) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
using System;
namespace ABC105B {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
Boolean buy = false;
for (int i = 0; i < (N / 4) + 1; i++) {
for (int j = 0; j < (N / 7) + 1; j++) {
if (4 * i + 7 * j == N)
buy = true;
}
}
if (buy) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 72], ["+", 0, 57, 15, 16, 31, 16, 12, 16, 17, 48]]
| 8
| 128
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC105_20200320B.Input;
namespace ABC105_20200320B {
static class Input {
/// <summary>
/// 1行の入力をTに応じてリストに変換する関数を返す
/// </summary>
static Func<string, List<T>>
Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToList();
/// <summary>
/// 1行の入力をTに応じて変換する関数を返す
/// </summary>
static Func<string, T> Convert<T>() {
Type t = typeof(T);
if (t == typeof(string))
return _ => (T)(object)_;
if (t == typeof(int))
return _ => (T)(object) int.Parse(_);
if (t == typeof(long))
return _ => (T)(object) long.Parse(_);
if (t == typeof(double))
return _ => (T)(object) double.Parse(_);
if (t == typeof(List<string>))
return _ => (T)(object)Cast<string>()(_);
if (t == typeof(List<int>))
return _ => (T)(object)Cast<int>()(_);
if (t == typeof(List<long>))
return _ => (T)(object)Cast<long>()(_);
if (t == typeof(List<double>))
return _ => (T)(object)Cast<double>()(_);
throw new NotSupportedException(t + "is not supported.");
}
static T Convert<T>(string s) => Convert<T>()(s);
static string String() => Console.ReadLine();
static List<string>
String(long rowNumber) => new bool [rowNumber].Select(_ => String()).ToList();
/// <summary>
/// 1行の値の入力
/// </summary>
public static void Cin<T>(out T a) => a = Convert<List<T>>(String())[0];
public static void Cin<T1, T2>(out T1 a1, out T2 a2) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
}
public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
}
public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
a4 = Convert<T4>(v[3]);
}
public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4, out T5 a5) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
a4 = Convert<T4>(v[3]);
a5 = Convert<T5>(v[4]);
}
public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2,
out T3 a3, out T4 a4,
out T5 a5, out T6 a6) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
a4 = Convert<T4>(v[3]);
a5 = Convert<T5>(v[4]);
a6 = Convert<T6>(v[5]);
}
/// <summary>
/// 複数行の値の入力
/// </summary>
public static void
Cin<T>(long n, out List<T> l) => l = String(n).Select(Convert<T>()).ToList();
public static void Cin<T1, T2>(long n, out List<T1> l1, out List<T2> l2) {
l1 = new List<T1>();
l2 = new List<T2>();
foreach (List<string> l in String(n).Select(Convert<List<string>>())) {
l1.Add(Convert<T1>(l[0]));
l2.Add(Convert<T2>(l[1]));
}
}
public static void Cin<T1, T2, T3>(long n, out List<T1> l1, out List<T2> l2,
out List<T3> l3) {
l1 = new List<T1>();
l2 = new List<T2>();
l3 = new List<T3>();
foreach (List<string> l in String(n).Select(Convert<List<string>>())) {
l1.Add(Convert<T1>(l[0]));
l2.Add(Convert<T2>(l[1]));
l3.Add(Convert<T3>(l[2]));
}
}
public static void Cin<T1, T2, T3, T4>(long n, out List<T1> l1,
out List<T2> l2, out List<T3> l3,
out List<T4> l4) {
l1 = new List<T1>();
l2 = new List<T2>();
l3 = new List<T3>();
l4 = new List<T4>();
foreach (List<string> l in String(n).Select(Convert<List<string>>())) {
l1.Add(Convert<T1>(l[0]));
l2.Add(Convert<T2>(l[1]));
l3.Add(Convert<T3>(l[2]));
l4.Add(Convert<T4>(l[3]));
}
}
/// <summary>
/// 1行に書かれた複数の値の入力
/// </summary>
public static void
Cin<T>(out List<T> lArr) => lArr = Convert<List<T>>(String());
/// <summary>
/// h行の行列の入力
/// </summary>
public static void Cin<T>(long h, out List<List<T>> map) => map =
String(h).Select(Convert<List<T>>()).ToList();
}
class Program {
public static void Main(string[] args) {
StreamWriter streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
new Solver().Solve();
Console.Out.Flush();
}
public static void Debug() { new Solver().Solve(); }
}
class Solver {
public void Solve() {
long N;
Cin(out N);
for (int i = 0; i < N / 4; i++) {
for (int j = 0; j < N / 7; j++) {
if (i * 4 + 7 * j == N) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static ABC105_20200320B.Input;
namespace ABC105_20200320B {
static class Input {
/// <summary>
/// 1行の入力をTに応じてリストに変換する関数を返す
/// </summary>
static Func<string, List<T>>
Cast<T>() => _ => _.Split(' ').Select(Convert<T>()).ToList();
/// <summary>
/// 1行の入力をTに応じて変換する関数を返す
/// </summary>
static Func<string, T> Convert<T>() {
Type t = typeof(T);
if (t == typeof(string))
return _ => (T)(object)_;
if (t == typeof(int))
return _ => (T)(object) int.Parse(_);
if (t == typeof(long))
return _ => (T)(object) long.Parse(_);
if (t == typeof(double))
return _ => (T)(object) double.Parse(_);
if (t == typeof(List<string>))
return _ => (T)(object)Cast<string>()(_);
if (t == typeof(List<int>))
return _ => (T)(object)Cast<int>()(_);
if (t == typeof(List<long>))
return _ => (T)(object)Cast<long>()(_);
if (t == typeof(List<double>))
return _ => (T)(object)Cast<double>()(_);
throw new NotSupportedException(t + "is not supported.");
}
static T Convert<T>(string s) => Convert<T>()(s);
static string String() => Console.ReadLine();
static List<string>
String(long rowNumber) => new bool [rowNumber].Select(_ => String()).ToList();
/// <summary>
/// 1行の値の入力
/// </summary>
public static void Cin<T>(out T a) => a = Convert<List<T>>(String())[0];
public static void Cin<T1, T2>(out T1 a1, out T2 a2) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
}
public static void Cin<T1, T2, T3>(out T1 a1, out T2 a2, out T3 a3) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
}
public static void Cin<T1, T2, T3, T4>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
a4 = Convert<T4>(v[3]);
}
public static void Cin<T1, T2, T3, T4, T5>(out T1 a1, out T2 a2, out T3 a3,
out T4 a4, out T5 a5) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
a4 = Convert<T4>(v[3]);
a5 = Convert<T5>(v[4]);
}
public static void Cin<T1, T2, T3, T4, T5, T6>(out T1 a1, out T2 a2,
out T3 a3, out T4 a4,
out T5 a5, out T6 a6) {
var v = Convert<List<string>>(String());
a1 = Convert<T1>(v[0]);
a2 = Convert<T2>(v[1]);
a3 = Convert<T3>(v[2]);
a4 = Convert<T4>(v[3]);
a5 = Convert<T5>(v[4]);
a6 = Convert<T6>(v[5]);
}
/// <summary>
/// 複数行の値の入力
/// </summary>
public static void
Cin<T>(long n, out List<T> l) => l = String(n).Select(Convert<T>()).ToList();
public static void Cin<T1, T2>(long n, out List<T1> l1, out List<T2> l2) {
l1 = new List<T1>();
l2 = new List<T2>();
foreach (List<string> l in String(n).Select(Convert<List<string>>())) {
l1.Add(Convert<T1>(l[0]));
l2.Add(Convert<T2>(l[1]));
}
}
public static void Cin<T1, T2, T3>(long n, out List<T1> l1, out List<T2> l2,
out List<T3> l3) {
l1 = new List<T1>();
l2 = new List<T2>();
l3 = new List<T3>();
foreach (List<string> l in String(n).Select(Convert<List<string>>())) {
l1.Add(Convert<T1>(l[0]));
l2.Add(Convert<T2>(l[1]));
l3.Add(Convert<T3>(l[2]));
}
}
public static void Cin<T1, T2, T3, T4>(long n, out List<T1> l1,
out List<T2> l2, out List<T3> l3,
out List<T4> l4) {
l1 = new List<T1>();
l2 = new List<T2>();
l3 = new List<T3>();
l4 = new List<T4>();
foreach (List<string> l in String(n).Select(Convert<List<string>>())) {
l1.Add(Convert<T1>(l[0]));
l2.Add(Convert<T2>(l[1]));
l3.Add(Convert<T3>(l[2]));
l4.Add(Convert<T4>(l[3]));
}
}
/// <summary>
/// 1行に書かれた複数の値の入力
/// </summary>
public static void
Cin<T>(out List<T> lArr) => lArr = Convert<List<T>>(String());
/// <summary>
/// h行の行列の入力
/// </summary>
public static void Cin<T>(long h, out List<List<T>> map) => map =
String(h).Select(Convert<List<T>>()).ToList();
}
class Program {
public static void Main(string[] args) {
StreamWriter streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(streamWriter);
new Solver().Solve();
Console.Out.Flush();
}
public static void Debug() { new Solver().Solve(); }
}
class Solver {
public void Solve() {
long N;
Cin(out N);
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
if (i * 4 + 7 * j == N) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 85], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 12, 203]]
| 8
| 1,656
| 8
|
using System;
using System.Collections.Generic;
using System.Linq;
static class MainClass {
public static void Main(string[] args) {
// var temp = Console.ReadLine().Split(' ').Select(long.Parse);
var N = int.Parse(Console.ReadLine());
var ans = "No";
for (var i = 0; i < N / 4; i++) {
for (var j = 0; j < N / 7; j++) {
if (i * 4 + j * 7 == N) {
ans = "Yes";
break;
}
}
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
static class MainClass {
public static void Main(string[] args) {
// var temp = Console.ReadLine().Split(' ').Select(long.Parse);
var N = int.Parse(Console.ReadLine());
var ans = "No";
for (var i = 0; i <= N / 4; i++) {
for (var j = 0; j <= N / 7; j++) {
if (i * 4 + j * 7 == N) {
ans = "Yes";
break;
}
}
}
Console.WriteLine(ans);
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 119
| 4
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
WriteLine(Solve());
// ReadKey();
}
static string Solve() {
var n = ScanInt();
for (int i = 0; i <= 25; i++)
if ((n - 4 * i) % 7 == 0)
return "Yes";
return "No";
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static System.Console;
using static Program.Input;
using static Program.MyMath;
using static Program.Const;
namespace Program {
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
public static class Program {
public static void Main() {
WriteLine(Solve());
// ReadKey();
}
static string Solve() {
var n = ScanInt();
for (int i = 0; i <= 25 && i * 4 <= n; i++)
if ((n - 4 * i) % 7 == 0)
return "Yes";
return "No";
}
}
static class Input {
public static void InputLine(out int a, out int b) {
var input = ScanIntArray();
a = input[0];
b = input[1];
}
public static void InputLine(out int a, out int b, out int c) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out int a, out int b, out int c, out int d) {
var input = ScanIntArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out long a, out long b) {
var input = ScanLongArray();
a = input[0];
b = input[1];
}
public static void InputLine(out long a, out long b, out long c) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
}
public static void InputLine(out long a, out long b, out long c, out long d) {
var input = ScanLongArray();
a = input[0];
b = input[1];
c = input[2];
d = input[3];
}
public static void InputLine(out string a, out string b) {
var input = ScanStrArray();
a = input[0];
b = input[1];
}
public static int ScanInt() { return int.Parse(ReadLine()); }
static public uint ScanUint() { return uint.Parse(ReadLine()); }
static public double ScanDouble() { return double.Parse(ReadLine()); }
static public long ScanLong() { return long.Parse(ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(ReadLine()); }
static public int[] ScanIntArray() {
return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
}
static class MyMath {
static public int CountBit(this long a) {
if (a == 0)
return 0;
int c = 1;
for (; a > 1; a /= 2)
if (a % 2 == 1)
c++;
return c;
}
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++)
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = MOD) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
public static long ModPow(long a, long n, long m = MOD) {
long res = 1;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % m;
a = (a * a) % m;
n >>= 1;
}
return res;
}
}
static class MyLinq {
public static void Sort(this string[] array) {
Array.Sort(array, StringComparer.OrdinalIgnoreCase);
}
public static void StringSort(this List<string> list) {
list.Sort(StringComparer.OrdinalIgnoreCase);
}
public static string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
public static IEnumerable<TItem>
Distinct<TItem, TKey>(this IEnumerable<TItem> source,
Func<TItem, TKey> keySelector) {
if (source == null)
throw new ArgumentNullException(nameof(source));
if (keySelector == null)
throw new ArgumentNullException(nameof(keySelector));
var set = new HashSet<TKey>();
foreach (var item in source)
if (set.Add(keySelector(item)))
yield return item;
}
}
}
|
[["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 98], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 31, 22], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 19], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 22]]
| 8
| 2,014
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;
namespace Atcoder {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
for (int i = 1; i <= N / 4; i++) {
for (int j = 1; j <= N / 7; j++) {
if (N == (4 * i) + (7 * j)) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;
namespace Atcoder {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
for (int i = 0; i <= N / 7; i++) {
for (int j = 0; j <= N / 4; j++) {
if (N == (7 * i) + (4 * j)) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["-", 15, 16, 12, 16, 31, 23, 0, 16, 31, 203], ["+", 15, 16, 12, 16, 31, 23, 0, 16, 31, 203], ["-", 15, 16, 12, 16, 12, 23, 0, 16, 31, 203], ["+", 15, 16, 12, 16, 12, 23, 0, 16, 31, 203]]
| 8
| 129
| 12
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
bool ans = false;
foreach (var x in Enumerable.Range(0, 100)
.Select(n => n * 7)
.TakeWhile(n => n <= N)) {
if ((N - x) % 4 == 0) {
ans = true;
}
}
Console.WriteLine(ans ? "YES" : "NO");
}
}
static class MathUtil {
public static IEnumerable<IEnumerable<int>> GetPermutation(int n) {
if (n == 0) {
yield return Single(0);
yield break;
}
for (int i = 0; i <= n; i++) {
foreach (var x in GetPermutation(n - 1)) {
yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
}
}
}
private static IEnumerable<int> Single(int x) { yield return x; }
public static IEnumerable<int> EnumeratePrimeNumbers() {
List<int> primes = new List<int>() { 2 };
yield return 2;
for (int i = 3; i < int.MaxValue; i++) {
bool isPrime = true;
int Sqrt = (int)Math.Sqrt(i) + 1;
foreach (var prime in primes) {
if (prime > Sqrt) {
break;
}
if (i % prime == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.Add(i);
yield return i;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;
class Program {
static void Main() {
int N = int.Parse(Console.ReadLine());
bool ans = false;
foreach (var x in Enumerable.Range(0, 100)
.Select(n => n * 7)
.TakeWhile(n => n <= N)) {
if ((N - x) % 4 == 0) {
ans = true;
}
}
Console.WriteLine(ans ? "Yes" : "No");
}
}
static class MathUtil {
public static IEnumerable<IEnumerable<int>> GetPermutation(int n) {
if (n == 0) {
yield return Single(0);
yield break;
}
for (int i = 0; i <= n; i++) {
foreach (var x in GetPermutation(n - 1)) {
yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
}
}
}
private static IEnumerable<int> Single(int x) { yield return x; }
public static IEnumerable<int> EnumeratePrimeNumbers() {
List<int> primes = new List<int>() { 2 };
yield return 2;
for (int i = 3; i < int.MaxValue; i++) {
bool isPrime = true;
int Sqrt = (int)Math.Sqrt(i) + 1;
foreach (var prime in primes) {
if (prime > Sqrt) {
break;
}
if (i % prime == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.Add(i);
yield return i;
}
}
}
}
|
[["-", 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
| 371
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
//[summary]B - Cakes and Donuts
int n = int.Parse(Console.ReadLine());
if (CanBuyCakesAndDonuts(n)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
static bool CanBuyCakesAndDonuts(int n) {
for (int i = 0; i * 7 < n; i++) {
if ((n - i * 7) % 4 == 0) {
return true;
}
}
return false;
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
//[summary]B - Cakes and Donuts
int n = int.Parse(Console.ReadLine());
if (CanBuyCakesAndDonuts(n)) {
Console.WriteLine("Yes");
} else {
Console.WriteLine("No");
}
}
static bool CanBuyCakesAndDonuts(int n) {
for (int i = 0; i * 7 <= n; i++) {
if ((n - i * 7) % 4 == 0) {
return true;
}
}
return false;
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 128
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var N = int.Parse(ReadLine());
for (int i = 1; i * 4 <= N; i++) {
var num = N;
num = num - i * 4;
if (num < 0)
continue;
for (int j = 0; num >= j * 7; j++) {
if (num - j * 7 == 0) {
WriteLine("Yes");
return;
}
}
}
WriteLine("No");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
namespace AtCoder {
class Program {
static void Main() {
var N = int.Parse(ReadLine());
for (int i = 0; i * 4 <= N; i++) {
var num = N;
num = num - i * 4;
if (num < 0)
continue;
for (int j = 0; num >= j * 7; j++) {
if (num - j * 7 == 0) {
WriteLine("Yes");
return;
}
}
}
WriteLine("No");
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 133
| 2
|
using System;
namespace B.Cakes_and_Donuts {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
int ans = 0;
for (int i = 4; i <= N; i += 4)
for (int j = 7; j <= N - i; j += 7)
if ((i + j) == N) {
ans++;
break;
}
if (ans > 0)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
namespace B.Cakes_and_Donuts {
class Program {
static void Main(string[] args) {
var N = int.Parse(Console.ReadLine());
int ans = 0;
for (int i = 0; i <= N; i += 4)
for (int j = 0; j <= N - i; j += 7)
if ((i + j) == N) {
ans++;
break;
}
if (ans > 0)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 8, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 117
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace MyProgram {
public class Program {
public static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
bool ok = false;
int a = 4;
while (a < n) {
if ((n - a) % 7 == 0)
ok = true;
a += 4;
}
a = 7;
while (a < n) {
if ((n - a) % 4 == 0)
ok = true;
a += 7;
}
if (ok)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace MyProgram {
public class Program {
public static void Main(string[] args) {
int n = int.Parse(Console.ReadLine());
bool ok = false;
int a = 4;
while (a <= n) {
if ((n - a) % 7 == 0)
ok = true;
a += 4;
}
a = 7;
while (a <= n) {
if ((n - a) % 4 == 0)
ok = true;
a += 7;
}
if (ok)
Console.WriteLine("Yes");
else
Console.WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 52, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 19]]
| 8
| 148
| 4
|
using static System.Console;
namespace AtCorder {
public class Program {
public static void Main() {
var n = int.Parse(ReadLine());
for (int i = 0; i < n; i += 4) {
for (int j = 0; j <= n; j += 7) {
if (i + j == n) {
WriteLine("Yes");
return;
}
}
}
WriteLine("No");
}
}
}
|
using static System.Console;
namespace AtCorder {
public class Program {
public static void Main() {
var n = int.Parse(ReadLine());
for (int i = 0; i <= n; i += 4) {
for (int j = 0; j <= n; j += 7) {
if (i + j == n) {
WriteLine("Yes");
return;
}
}
}
WriteLine("No");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
| 8
| 95
| 2
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
string output = "";
float cakesNum = 0;
int donutsNum = 0;
output = "No";
for (int i = 0; n - 7 * i > 0; i++) {
cakesNum = (n - 7 * i) / 4f;
// Console.WriteLine(cakesNum);
if (cakesNum == (int)cakesNum) {
output = "Yes";
break;
}
}
//出力
Console.WriteLine(output);
}
}
|
using System;
class Program {
static void Main(string[] args) {
string[] str = Console.ReadLine().Split(' ');
int n = int.Parse(str[0]);
string output = "";
float cakesNum = 0;
int donutsNum = 0;
output = "No";
for (int i = 0; n - 7 * i >= 0; i++) {
cakesNum = (n - 7 * i) / 4f;
// Console.WriteLine(cakesNum);
if (cakesNum == (int)cakesNum) {
output = "Yes";
break;
}
}
//出力
Console.WriteLine(output);
}
}
|
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 47], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 20]]
| 8
| 131
| 2
|
using System;
class Program {
static void Main(string[] args) {
int N;
N = int.Parse(Console.ReadLine());
bool f = false;
for (int i = 1; i < 26; i++) {
for (int j = 1; j < 15; j++) {
if (4 * i + 7 * j == N) {
if (!f) {
Console.WriteLine("Yes");
}
f = true;
break;
}
}
}
if (!f) {
Console.WriteLine("No");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
int N;
N = int.Parse(Console.ReadLine());
bool f = false;
for (int i = 0; i < 26; i++) {
for (int j = 0; j < 15; j++) {
if (4 * i + 7 * j == N) {
if (!f) {
Console.WriteLine("Yes");
}
f = true;
break;
}
}
}
if (!f) {
Console.WriteLine("No");
}
}
}
|
[["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 123
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { ABC105.C(); }
class ABC105 {
public static void A() {
var N = Read.Int();
var K = Read.Int();
Console.WriteLine(N % K == 0 ? 0 : 1);
}
public static void B() {
var N = Read.Int();
for (int i = 0; i <= 25; ++i) {
for (int j = 0; j <= 15; ++j) {
if (i * 4 + j * 7 == N) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
public static void C() {
var N = Read.Int();
if (N == 0) {
Console.WriteLine(0);
return;
}
bool negative = N < 0;
N = Math.Abs(N);
var ans = new List<int>();
int d = negative ? -1 : 1;
for (int i = 0;; ++i) {
if ((N & (1 << i)) > 0) {
ans.Add(1);
N -= d;
} else {
ans.Add(0);
}
if (N == 0) {
break;
}
d *= -2;
}
ans.Reverse();
Console.WriteLine(String.Join("", ans));
}
public static void D() {
var N = Read.Int();
var M = Read.Long();
var A = Read.LongN();
var ASum = Util.ASum(A).Select(x => x % M).ToArray();
var freq = Util.Frequency(ASum);
Console.WriteLine(freq.Values.Select(x => x * (x - 1) / 2).Sum());
}
}
class Util {
public static long[] ASum(long[] array) {
var res = new long[array.Length + 1];
for (int i = 0; i < array.Length; ++i) {
res[i + 1] = res[i] + array[i];
}
return res;
}
public static Dictionary<T, long> Frequency<T>(T[] array) {
var dict = new Dictionary<T, long>();
foreach (var a in array) {
if (!dict.ContainsKey(a)) {
dict.Add(a, 0);
}
dict[a]++;
}
return dict;
}
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static ulong[] ULongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToUInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>>
AdjacencyList(int N, int M, bool isDirectional = false) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
if (!dict[ab[0]].Contains(ab[1])) {
dict[ab[0]].Add(ab[1]);
}
if (!isDirectional && !dict[ab[1]].Contains(ab[0])) {
dict[ab[1]].Add(ab[0]);
}
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace Contest {
class Program {
static void Main(string[] args) { ABC105.C(); }
class ABC105 {
public static void A() {
var N = Read.Int();
var K = Read.Int();
Console.WriteLine(N % K == 0 ? 0 : 1);
}
public static void B() {
var N = Read.Int();
for (int i = 0; i <= 25; ++i) {
for (int j = 0; j <= 15; ++j) {
if (i * 4 + j * 7 == N) {
Console.WriteLine("Yes");
return;
}
}
}
Console.WriteLine("No");
}
public static void C() {
var N = Read.Long();
if (N == 0) {
Console.WriteLine(0);
return;
}
bool negative = N < 0;
N = Math.Abs(N);
var ans = new List<int>();
long d = negative ? -1 : 1;
for (int i = 0;; ++i) {
if ((N & (1L << i)) > 0) {
ans.Add(1);
N -= d;
} else {
ans.Add(0);
}
if (N == 0) {
break;
}
d *= -2;
}
ans.Reverse();
Console.WriteLine(String.Join("", ans));
}
public static void D() {
var N = Read.Int();
var M = Read.Long();
var A = Read.LongN();
var ASum = Util.ASum(A).Select(x => x % M).ToArray();
var freq = Util.Frequency(ASum);
Console.WriteLine(freq.Values.Select(x => x * (x - 1) / 2).Sum());
}
}
class Util {
public static long[] ASum(long[] array) {
var res = new long[array.Length + 1];
for (int i = 0; i < array.Length; ++i) {
res[i + 1] = res[i] + array[i];
}
return res;
}
public static Dictionary<T, long> Frequency<T>(T[] array) {
var dict = new Dictionary<T, long>();
foreach (var a in array) {
if (!dict.ContainsKey(a)) {
dict.Add(a, 0);
}
dict[a]++;
}
return dict;
}
}
static class Read {
static Queue<string> queue = new Queue<string>();
static void Enqueue() {
var ss = Console.ReadLine().Split(' ');
foreach (var s in ss) {
queue.Enqueue(s);
}
}
public static int Int() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt32(queue.Dequeue());
}
public static long Long() {
if (queue.Count == 0) {
Enqueue();
}
return Convert.ToInt64(queue.Dequeue());
}
public static string Str() {
if (queue.Count == 0) {
Enqueue();
}
return queue.Dequeue();
}
public static int[] IntN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt32(s))
.ToArray();
}
public static long[] LongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToInt64(s))
.ToArray();
}
public static ulong[] ULongN() {
return Console.ReadLine()
.Split(' ')
.Select(s => Convert.ToUInt64(s))
.ToArray();
}
public static string[] StrN() { return Console.ReadLine().Split(' '); }
public static Tuple<int, int>[] TupleInt(int n) {
List<Tuple<int, int>> list = new List<Tuple<int, int>>();
for (int i = 0; i < n; ++i) {
var ab = Read.IntN();
list.Add(new Tuple<int, int>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<long, long>[] TupleLong(int n) {
List<Tuple<long, long>> list = new List<Tuple<long, long>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<long, long>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<string, string>[] TupleStr(int n) {
List<Tuple<string, string>> list = new List<Tuple<string, string>>();
for (int i = 0; i < n; ++i) {
var ab = Read.StrN();
list.Add(new Tuple<string, string>(ab[0], ab[1]));
}
return list.ToArray();
}
public static Tuple<double, double>[] TupleDouble(int n) {
List<Tuple<double, double>> list = new List<Tuple<double, double>>();
for (int i = 0; i < n; ++i) {
var ab = Read.LongN();
list.Add(new Tuple<double, double>(ab[0], ab[1]));
}
return list.ToArray();
}
public static long[,] LongMatrix(int r, int c) {
var mat = new long[r, c];
for (int i = 0; i < r; ++i) {
var x = Read.LongN();
for (int j = 0; j < c; ++j) {
mat[i, j] = x[j];
}
}
return mat;
}
public static Dictionary<int, HashSet<int>>
AdjacencyList(int N, int M, bool isDirectional = false) {
Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new HashSet<int>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
if (!dict[ab[0]].Contains(ab[1])) {
dict[ab[0]].Add(ab[1]);
}
if (!isDirectional && !dict[ab[1]].Contains(ab[0])) {
dict[ab[1]].Add(ab[0]);
}
}
return dict;
}
public static Dictionary<int, Dictionary<int, long>>
AdjacencyListWithWeight(int N, int M) {
Dictionary<int, Dictionary<int, long>> dict =
new Dictionary<int, Dictionary<int, long>>();
for (int i = 0; i <= N; ++i) {
dict.Add(i, new Dictionary<int, long>());
}
for (int i = 0; i < M; ++i) {
var ab = Read.IntN();
dict[ab[0]].Add(ab[1], ab[2]);
dict[ab[1]].Add(ab[0], ab[2]);
}
return dict;
}
}
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 141, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 31, 23, 0, 16, 12, 23, 0, 16, 31, 203], ["+", 31, 23, 0, 16, 12, 23, 0, 16, 31, 203]]
| 8
| 1,673
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp90 {
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
int k = 0;
int keta = 0;
if (N > 0) {
k = (int)Math.Ceiling(Math.Log10(3 * N + 1) / Math.Log10(4)) - 1;
keta = 2 * k + 1;
} else if (N < 0) {
k = (int)Math.Ceiling(Math.Log10(1 - 1.5f * N) / Math.Log10(4));
keta = 2 * k;
} else {
Console.WriteLine(0);
return;
}
string ans = "";
for (int i = 0; i < keta; i++) {
if (N % 2 == 0) {
ans = "0" + ans;
} else {
ans = "1" + ans;
N -= 1;
}
N /= -2;
}
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp90 {
class Program {
static void Main(string[] args) {
long N = long.Parse(Console.ReadLine());
int k = 0;
int keta = 0;
if (N > 0) {
k = (int)Math.Ceiling(Math.Log10(3 * N + 1) / Math.Log10(4)) - 1;
keta = 2 * k + 1;
} else if (N < 0) {
k = (int)Math.Ceiling(Math.Log10(1 - 1.5f * N) / Math.Log10(4));
keta = 2 * k;
} else {
Console.WriteLine(0);
return;
}
string ans = "";
for (int i = 0; i < keta; i++) {
if (N % 2 == 0) {
ans = "0" + ans;
} else {
ans = "1" + ans;
N -= 1;
}
N /= -2;
}
Console.WriteLine(ans);
}
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 199]]
| 8
| 238
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string ans = "";
while (N != 0) {
if (N % -2 == 0) {
ans = "0" + ans;
} else {
ans = "1" + ans;
}
N = N / -2;
}
if (ans == "") {
Console.WriteLine(0);
} else {
Console.WriteLine(ans);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
int N = int.Parse(Console.ReadLine());
string ans = "";
while (N != 0) {
if (N % -2 == 0) {
ans = "0" + ans;
} else {
ans = "1" + ans;
N--;
}
N = N / -2;
}
if (ans == "") {
Console.WriteLine(0);
} else {
Console.WriteLine(ans);
}
}
}
|
[["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 22], ["+", 0, 57, 75, 196, 0, 1, 0, 223, 0, 68], ["+", 8, 196, 0, 57, 75, 196, 0, 1, 0, 35]]
| 8
| 121
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
class Procon {
public Procon() {}
static void Main(string[] agrs) { new Procon().Do(); }
Scanner cin;
public void Do() {
cin = new Scanner();
int N = cin.nextInt();
string S = "";
int tmp = -2;
while (true) {
if (N == 0) {
break;
}
if (N % tmp != 0) {
S = "1" + S;
N -= tmp / -2;
} else {
S = "0" + S;
}
tmp *= -2;
}
if (S == "") {
S = "0";
}
Console.WriteLine(S);
}
}
class Scanner {
string[] s;
int i;
int max_i;
public Scanner() {
s = new string[0];
max_i = 0;
i = 0;
}
public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
} else {
return s[i++];
}
}
public int nextInt() { return int.Parse(nextString()); }
public long nextLong() { return long.Parse(nextString()); }
public double nextDouble() { return double.Parse(nextString()); }
public string[] arrayString() { return Console.ReadLine().Split(' '); }
public int[] arrayInt() {
string[] str = Console.ReadLine().Split(' ');
int[] array = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = int.Parse(str[i]);
}
return array;
}
public long[] arrayLong() {
string[] str = Console.ReadLine().Split(' ');
long[] array = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = long.Parse(str[i]);
}
return array;
}
public double[] arrayDouble() {
string[] str = Console.ReadLine().Split(' ');
double[] array = new double[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = double.Parse(str[i]);
}
return array;
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Procon {
public Procon() {}
static void Main(string[] agrs) { new Procon().Do(); }
Scanner cin;
public void Do() {
cin = new Scanner();
long N = cin.nextInt();
string S = "";
long tmp = -2;
while (true) {
if (N == 0) {
break;
}
if (N % tmp != 0) {
S = "1" + S;
N -= tmp / -2;
} else {
S = "0" + S;
}
tmp *= -2;
}
if (S == "") {
S = "0";
}
Console.WriteLine(S);
}
}
class Scanner {
string[] s;
int i;
int max_i;
public Scanner() {
s = new string[0];
max_i = 0;
i = 0;
}
public string nextString() {
if (i >= s.Length) {
s = Console.ReadLine().Split(' ');
max_i = s.Length;
i = 0;
if (max_i == 0) {
return "";
}
return s[i++];
} else {
return s[i++];
}
}
public int nextInt() { return int.Parse(nextString()); }
public long nextLong() { return long.Parse(nextString()); }
public double nextDouble() { return double.Parse(nextString()); }
public string[] arrayString() { return Console.ReadLine().Split(' '); }
public int[] arrayInt() {
string[] str = Console.ReadLine().Split(' ');
int[] array = new int[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = int.Parse(str[i]);
}
return array;
}
public long[] arrayLong() {
string[] str = Console.ReadLine().Split(' ');
long[] array = new long[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = long.Parse(str[i]);
}
return array;
}
public double[] arrayDouble() {
string[] str = Console.ReadLine().Split(' ');
double[] array = new double[str.Length];
for (int i = 0; i < str.Length; i++) {
array[i] = double.Parse(str[i]);
}
return array;
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199]]
| 8
| 572
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
class Cmondai {
static void Main() {
var N = Int32.Parse(Console.ReadLine());
const int constant = -2;
var num = 1;
var ans = new Stack<char>();
if (N == 0)
ans.Push('0');
while (N != 0) {
//余りが0
// 1が立たないので数に変化なし
if (N % (num * constant) == 0) {
ans.Push('0');
}
//余りが1
// 1が立つのでその分Nから数を引く
else {
ans.Push('1');
N -= num;
}
num *= (-2);
}
var count = ans.Count();
for (int i = 0; i < count; ++i)
Console.Write(ans.Pop());
Console.WriteLine();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
class Cmondai {
static void Main() {
var N = Int64.Parse(Console.ReadLine());
const long constant = -2;
var num = 1L;
var ans = new Stack<char>();
if (N == 0)
ans.Push('0');
while (N != 0) {
//余りが0
// 1が立たないので数に変化なし
if (N % (num * constant) == 0) {
ans.Push('0');
}
//余りが1
// 1が立つのでその分Nから数を引く
else {
ans.Push('1');
N -= num;
}
num *= (-2);
}
long count = ans.Count();
for (long i = 0; i < count; ++i)
Console.Write(ans.Pop());
Console.WriteLine();
}
}
|
[["-", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["+", 0, 200, 0, 212, 0, 213, 63, 214, 205, 22], ["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 197, 0, 198, 0, 200, 0, 212, 0, 203], ["-", 8, 196, 0, 197, 0, 198, 39, 216, 0, 217], ["-", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199], ["+", 0, 195, 8, 196, 0, 7, 10, 198, 39, 199]]
| 8
| 176
| 10
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
//[summary]C - Base -2 Number
int n = int.Parse(Console.ReadLine());
string minus2Str = ConvertBaseNumber(n, -2);
Console.WriteLine(minus2Str);
}
static string ConvertBaseNumber(int sourceNum, int n) {
//[summary]10進法の数字をn進法に変換
//変換方法については、以下リンクの最下部を参照
// http://manabi.matiralab.com/binary/
var mods = new List<int>();
int num = sourceNum;
//元の数字が"n"で割れなくなるまで繰り返し
while (num != 1) {
if (num < 0 && num % n != 0) {
mods.Add(1);
num = (num - 1) / n;
} else {
mods.Add(num % n);
num /= n;
}
}
mods.Add(num);
//記憶した数字の順番を入れ替える
mods.Reverse();
// Listの値を結合
return string.Join("", mods);
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
namespace AtCoder {
class Program {
static void Main(string[] args) {
//[summary]C - Base -2 Number
int n = int.Parse(Console.ReadLine());
string minus2Str = ConvertBaseNumber(n, -2);
Console.WriteLine(minus2Str);
}
static string ConvertBaseNumber(int sourceNum, int n) {
//[summary]10進法の数字をn進法に変換
//変換方法については、以下リンクの最下部を参照
// http://manabi.matiralab.com/binary/
var mods = new List<int>();
int num = sourceNum;
//元の数字が"n"で割れなくなるまで繰り返し
while (num != 0 && num != 1) {
if (num < 0 && num % n != 0) {
mods.Add(1);
num = (num - 1) / n;
} else {
mods.Add(num % n);
num /= n;
}
}
mods.Add(num);
//記憶した数字の順番を入れ替える
mods.Reverse();
// Listの値を結合
return string.Join("", mods);
}
}
}
|
[["+", 8, 196, 0, 52, 15, 16, 31, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 52, 15, 16, 17, 98], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 31, 22], ["+", 8, 196, 0, 52, 15, 16, 12, 16, 17, 79]]
| 8
| 180
| 4
|
using System;
public class Hello {
public static void Main() {
var n = int.Parse(Console.ReadLine());
var ans = "";
while (n != 0) {
if (n % -2 != 0) {
ans += "1";
n--;
} else {
ans += "0";
}
n /= -2;
}
Console.WriteLine((ans == "") ? "0" : ans);
}
}
|
using System;
public class Hello {
public static void Main() {
var n = int.Parse(Console.ReadLine());
var ans = "";
while (n != 0) {
if (n % -2 != 0) {
ans = "1" + ans;
n--;
} else {
ans = "0" + ans;
}
n /= -2;
}
Console.WriteLine((ans == "") ? "0" : ans);
}
}
|
[["-", 64, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 64, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 64, 196, 0, 1, 0, 11, 12, 16, 12, 22], ["-", 75, 196, 0, 1, 0, 11, 0, 202, 0, 107], ["+", 75, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 75, 196, 0, 1, 0, 11, 12, 16, 12, 22]]
| 8
| 96
| 8
|
using System;
namespace AtCoder.ABC104 {
public class A {
public static void Solve() {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
var rank = "";
if (a < 1200) {
rank = "ABC";
} else if (1200 <= a || a < 2800) {
rank = "ARC";
} else {
rank = "AGC";
}
Console.WriteLine(rank);
}
}
}
namespace AtCoder {
class Program {
static void Main(string[] args) { ABC104.A.Solve(); }
}
}
|
using System;
namespace AtCoder.ABC104 {
public class A {
public static void Solve() {
string[] input = Console.ReadLine().Split(' ');
int a = int.Parse(input[0]);
var rank = "";
if (a < 1200) {
rank = "ABC";
} else if (1200 <= a && a < 2800) {
rank = "ARC";
} else {
rank = "AGC";
}
Console.WriteLine(rank);
}
}
}
namespace AtCoder {
class Program {
static void Main(string[] args) { ABC104.A.Solve(); }
}
}
|
[["-", 8, 196, 0, 57, 75, 57, 15, 16, 17, 106], ["+", 8, 196, 0, 57, 75, 57, 15, 16, 17, 98]]
| 8
| 135
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class program {
static void Main(string[] args) {
int R = int.Parse(Console.ReadLine());
if (R < 2000) {
Console.WriteLine("ABC");
} else if (R < 2800) {
Console.WriteLine("ARC");
} else {
Console.WriteLine("AGC");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class program {
static void Main(string[] args) {
int R = int.Parse(Console.ReadLine());
if (R < 1200) {
Console.WriteLine("ABC");
} else if (R < 2800) {
Console.WriteLine("ARC");
} else {
Console.WriteLine("AGC");
}
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 103
| 2
|
using System;
class Program {
static void Main(string[] args) {
int n;
n = int.Parse(Console.ReadLine());
if (n < 1200) {
Console.WriteLine("ABC");
} else if (n <= 1200 && n < 2800) {
Console.WriteLine("ARC");
} else {
Console.WriteLine("AGC");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
int n;
n = int.Parse(Console.ReadLine());
if (n < 1200) {
Console.WriteLine("ABC");
} else if (n >= 1200 && n < 2800) {
Console.WriteLine("ARC");
} else {
Console.WriteLine("AGC");
}
}
}
|
[["-", 0, 57, 75, 57, 15, 16, 31, 16, 17, 19], ["+", 0, 57, 75, 57, 15, 16, 31, 16, 17, 20]]
| 8
| 85
| 2
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramB {
static void Main(string[] args) {
var s = Console.ReadLine();
if (s[0] != 'A') {
Console.WriteLine("WA");
return;
}
var cCount = 0;
var cPos = -1;
for (var i = 2; i < s.Length - 2; i++) {
if (s[i] == 'C') {
cCount++;
cPos = i;
}
}
if (cCount != 1) {
Console.WriteLine("WA");
return;
}
for (var i = 0; i < s.Length; i++) {
if (i == 0 || i == cPos)
continue;
if (!Char.IsLower(s[i])) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
namespace ABC {
class ProgramB {
static void Main(string[] args) {
var s = Console.ReadLine();
if (s[0] != 'A') {
Console.WriteLine("WA");
return;
}
var cCount = 0;
var cPos = -1;
for (var i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C') {
cCount++;
cPos = i;
}
}
if (cCount != 1) {
Console.WriteLine("WA");
return;
}
for (var i = 0; i < s.Length; i++) {
if (i == 0 || i == cPos)
continue;
if (!Char.IsLower(s[i])) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 202
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderB {
static void Main() {
var sc = new Scanner();
string s = sc.Next();
bool ok = true;
if (s.Substring(0, 1) != "A") {
ok = false;
}
if (!s.Substring(2, s.Length - 3).Contains("C")) {
ok = false;
}
int countA = 0;
int countC = 0;
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'A') {
countA++;
continue;
}
if (s[i] == 'C') {
countC++;
continue;
}
if (s[i] > 'z') {
ok = false;
}
}
if (!(countA == 1 && countC == 1)) {
ok = false;
}
string answer = ok ? "AC" : "WA";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class AtCoderB {
static void Main() {
var sc = new Scanner();
string s = sc.Next();
bool ok = true;
if (s.Substring(0, 1) != "A") {
ok = false;
}
if (!s.Substring(2, s.Length - 3).Contains("C")) {
ok = false;
}
int countA = 0;
int countC = 0;
for (int i = 0; i < s.Length; i++) {
if (s[i] == 'A') {
countA++;
continue;
}
if (s[i] == 'C') {
countC++;
continue;
}
if (s[i] < 'a') {
ok = false;
}
}
if (!(countA == 1 && countC == 1)) {
ok = false;
}
string answer = ok ? "AC" : "WA";
Console.WriteLine(answer);
}
class Scanner {
private string[] _line;
private int _index;
private const char Separator = ' ';
public Scanner() {
_line = new string[0];
_index = 0;
}
public string Next() {
while (_index >= _line.Length) {
_line = Console.ReadLine().Split(Separator);
_index = 0;
}
return _line[_index++];
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
public decimal NextDecimal() => decimal.Parse(Next());
public char NextChar() => Next()[0];
public char[] NextCharArray() => Next().ToCharArray();
public string[] Array() {
_line = Console.ReadLine().Split(Separator);
_index = _line.Length;
return _line;
}
public int[] IntArray() => Array().Select(int.Parse).ToArray();
public long[] LongArray() => Array().Select(long.Parse).ToArray();
public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 18], ["-", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 8, 196, 0, 57, 15, 16, 12, 252, 0, 253]]
| 8
| 518
| 4
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;
using static program.Const;
namespace program {
class Program {
static void Main() {
var s = ScanStr().ToCharArray();
if (s[0] != 'A') {
WriteLine("WA");
return;
}
int count = 0;
for (int i = 2; i < s.Length - 1; i++)
if (s[i] == 'C')
count++;
if (count != 1) {
WriteLine("WA");
return;
}
for (int i = 1; i < s.Length - 1; i++)
if (!(alp.Contains(s[i]) || s[i] == 'C')) {
WriteLine("WA");
return;
}
WriteLine("AC");
}
}
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
static class Input {
static public int ScanInt() { return int.Parse(Console.ReadLine()); }
static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
static public long ScanLong() { return long.Parse(Console.ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
static public int[] ScanIntArray() {
return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return Console.ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
static public string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
}
static class MyMath {
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++) {
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++) {
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = 1000000007) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
}
}
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;
using static program.Const;
namespace program {
class Program {
static void Main() {
var s = ScanStr().ToCharArray();
if (s[0] != 'A') {
WriteLine("WA");
return;
}
int count = 0;
for (int i = 2; i < s.Length - 1; i++)
if (s[i] == 'C')
count++;
if (count != 1) {
WriteLine("WA");
return;
}
for (int i = 1; i < s.Length; i++)
if (!(alp.Contains(s[i]) || s[i] == 'C')) {
WriteLine("WA");
return;
}
WriteLine("AC");
}
}
static class Const {
public static string alp = "abcdefghijklmnopqrstuvwxyz";
public static string Alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static long MOD = 1000000007;
public static int INF = int.MaxValue;
public static long INFL = long.MaxValue;
}
static class Input {
static public int ScanInt() { return int.Parse(Console.ReadLine()); }
static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
static public long ScanLong() { return long.Parse(Console.ReadLine()); }
static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
static public int[] ScanIntArray() {
return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
}
static public uint[] ScanUintArray() {
return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray();
}
static public double[] ScanDoubleArray() {
return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray();
}
static public long[] ScanLongArray() {
return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
}
static public ulong[] ScanUlongArray() {
return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
}
static public string ScanStr() { return Console.ReadLine(); }
static public string[] ScanStrArray() { return ScanStr().Split(); }
static public string RegaxReplace(this string arg1, string pattern,
string replacement) {
return Regex.Replace(arg1, pattern, replacement);
}
static public string Join<T>(this IEnumerable<T> source, string separator) {
return string.Join(separator, source);
}
}
static class MyMath {
static public int Floor2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public long Floor2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N / 2;
}
static public int Ceiling2(this int a) {
int N = 1;
while (N < a)
N *= 2;
return N;
}
static public long Ceiling2(this long a) {
long N = 1;
while (N < a)
N *= 2;
return N;
}
static public long[] CumSum(this long[] a) {
var res = new long[a.Length];
long s = 0;
for (int i = 0; i < a.Length; i++)
res[i] = (s += a[i]);
return res;
}
static public IEnumerable<int> PrimeFactors(this int n) {
int tmp = n;
for (int i = 2; i * i <= n; i++) {
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
}
if (tmp != 1)
yield return tmp;
}
static public IEnumerable<long> PrimeFactors(this long n) {
var tmp = n;
for (long i = 2; i * i <= n; i++) {
while (tmp % i == 0) {
tmp /= i;
yield return i;
}
}
if (tmp != 1)
yield return tmp;
}
static public int Digit(this int n, int d) {
if (d < 0)
return 0;
return (n % (int)Math.Pow(10, d + 1)) / (int)Math.Pow(10, d);
}
static public int Length(this int n) {
if (n < 0)
return 0;
return (int)Math.Log10(n) + 1;
}
static public int Top(this int n) { return n.Digit(n.Length() - 1); }
public static bool isPrime(this int p) {
if (p <= 1)
return false;
for (int i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static bool isPrime(this long p) {
if (p <= 1)
return false;
for (long i = 2; i * i <= p; i++)
if (p % i == 0)
return false;
return true;
}
public static int GCD(int a, int b) {
Func<int, int, int> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static long GCD(long a, long b) {
Func<long, long, long> gcd = null;
gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
return a > b ? gcd(a, b) : gcd(b, a);
}
public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
var d = extGCD(b, a % b, ref y, ref x);
y -= a / b * x;
return d;
}
public static int LCM(int a, int b) { return a * b / GCD(a, b); }
public static long LCM(long a, long b) { return a * b / GCD(a, b); }
public static long Inv(this long a, long m = 1000000007) {
long b = m, u = 1, v = 0;
while (b != 0) {
long t = a / b;
a -= t * b;
swap(ref a, ref b);
u -= t * v;
swap(ref u, ref v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
private static void swap(ref long a, ref long b) {
var t = a;
a = b;
b = t;
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 1,542
| 2
|
using System;
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
string T = Console.ReadLine();
bool flag = false;
char[] s = S.ToCharArray();
for (int j = 0; j < S.Length; j++) {
char tmp = s[s.Length - 1];
for (int i = s.Length - 1; i > 0; i--)
s[i] = s[i - 1];
s[0] = tmp;
S = new string(s);
if (S == T)
flag = true;
if (flag == true)
break;
}
if (flag == true)
Console.WriteLine("YES");
else
Console.WriteLine("NO");
}
}
|
using System;
class Program {
static void Main(string[] args) {
string S = Console.ReadLine();
string T = Console.ReadLine();
bool flag = false;
char[] s = S.ToCharArray();
for (int j = 0; j < S.Length; j++) {
char tmp = s[s.Length - 1];
for (int i = s.Length - 1; i > 0; i--)
s[i] = s[i - 1];
s[0] = tmp;
S = new string(s);
if (S == T)
flag = true;
if (flag == true)
break;
}
if (flag == true)
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
| 170
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
private static void print(object obj) { Console.WriteLine(obj); }
static void Main(string[] args) {
string a = Read();
string b = Read();
var c = a.ToList();
var d = b.ToList();
for (int j = 0; j < c.Count; j++) {
var aa = c.Last();
c.RemoveAt(c.Count - 1);
c.Insert(0, aa);
bool cc = true;
for (int i = 0; i < c.Count; i++) {
cc = (c[i] == d[i]) && cc;
if (!cc)
continue;
}
if (cc) {
print("yes");
return;
}
}
print("no");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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);
}
private static void print(object obj) { Console.WriteLine(obj); }
static void Main(string[] args) {
string a = Read();
string b = Read();
var c = a.ToList();
var d = b.ToList();
for (int j = 0; j < c.Count; j++) {
var aa = c.Last();
c.RemoveAt(c.Count - 1);
c.Insert(0, aa);
bool cc = true;
for (int i = 0; i < c.Count; i++) {
cc = (c[i] == d[i]) && cc;
if (!cc)
continue;
}
if (cc) {
print("Yes");
return;
}
}
print("No");
}
}
}
|
[["-", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 0, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 363
| 4
|
using System;
using System.Linq;
class prog {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans = 0;
for (int i = 0; i < N; i++) {
ans += a[i];
}
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
class prog {
static void Main() {
int N = int.Parse(Console.ReadLine());
int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
int ans = 0;
for (int i = 0; i < N; i++) {
ans += a[i] - 1;
}
Console.WriteLine(ans);
}
}
|
[["+", 8, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
| 8
| 94
| 2
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
class Program {
static void Main() {
int[] nm =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int N = nm[0];
int M = nm[1];
var requests = Enumerable.Range(0, M)
.Select(n => Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s))
.ToArray())
.Select(arr => new {
a = arr[0] - 1, b = arr[1] - 1
}) // 1スタートは扱いにくいから0スタートに治す
.ToArray();
//まとめられる区間はまとめていく。
//まとめるというのは、区間の重複領域を取ること。
//既存の区間のいずれかと重複している→それらを重複領域に置き換える。
//既存の区間のいずれとも重複していない→新規区間として登録。
requests = requests.OrderBy(req => req.a).ToArray();
int ans = 0;
int currentSt = requests[0].a;
int currentEd = requests[0].b - 1;
foreach (var req in requests.Skip(1)) {
if (req.a <= currentEd) {
currentSt = req.a;
currentEd = Math.Min(currentEd, req.b - 1);
} else {
ans++;
currentSt = req.a;
currentEd = req.b - 1;
}
}
if (currentSt != 0)
ans++;
Console.WriteLine(ans);
}
}
static class MathUtil {
public static IEnumerable<IEnumerable<int>> GetPermutation(int n) {
if (n == 0) {
yield return Single(0);
yield break;
}
for (int i = 0; i <= n; i++) {
foreach (var x in GetPermutation(n - 1)) {
yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
}
}
}
private static IEnumerable<int> Single(int x) { yield return x; }
public static IEnumerable<int> EnumeratePrimeNumbers() {
List<int> primes = new List<int>() { 2 };
yield return 2;
for (int i = 3; i < int.MaxValue; i++) {
bool isPrime = true;
int Sqrt = (int)Math.Sqrt(i) + 1;
foreach (var prime in primes) {
if (prime > Sqrt) {
break;
}
if (i % prime == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.Add(i);
yield return i;
}
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
class Program {
static void Main() {
int[] nm =
Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
int N = nm[0];
int M = nm[1];
var requests = Enumerable.Range(0, M)
.Select(n => Console.ReadLine()
.Split(' ')
.Select(s => int.Parse(s))
.ToArray())
.Select(arr => new {
a = arr[0] - 1, b = arr[1] - 1
}) // 1スタートは扱いにくいから0スタートに治す
.ToArray();
//まとめられる区間はまとめていく。
//まとめるというのは、区間の重複領域を取ること。
//既存の区間のいずれかと重複している→それらを重複領域に置き換える。
//既存の区間のいずれとも重複していない→新規区間として登録。
requests = requests.OrderBy(req => req.a).ToArray();
int ans = 0;
int currentSt = requests[0].a;
int currentEd = requests[0].b - 1;
foreach (var req in requests.Skip(1)) {
if (req.a <= currentEd) {
currentSt = req.a;
currentEd = Math.Min(currentEd, req.b - 1);
} else {
ans++;
currentSt = req.a;
currentEd = req.b - 1;
}
}
ans++;
Console.WriteLine(ans);
}
}
static class MathUtil {
public static IEnumerable<IEnumerable<int>> GetPermutation(int n) {
if (n == 0) {
yield return Single(0);
yield break;
}
for (int i = 0; i <= n; i++) {
foreach (var x in GetPermutation(n - 1)) {
yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
}
}
}
private static IEnumerable<int> Single(int x) { yield return x; }
public static IEnumerable<int> EnumeratePrimeNumbers() {
List<int> primes = new List<int>() { 2 };
yield return 2;
for (int i = 3; i < int.MaxValue; i++) {
bool isPrime = true;
int Sqrt = (int)Math.Sqrt(i) + 1;
foreach (var prime in primes) {
if (prime > Sqrt) {
break;
}
if (i % prime == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
primes.Add(i);
yield return i;
}
}
}
}
|
[["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 121], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 24], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 31, 22], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 79], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 8, 201, 0, 195, 8, 196, 0, 57, 0, 25]]
| 8
| 536
| 6
|
using System;
using System.Linq;
struct Demand {
public int a;
public int b;
public Demand(int a, int b) {
this.a = a;
this.b = b;
}
}
class Program {
static void Main(string[] args) {
var nmstr = Console.ReadLine().Split(' ');
var n = int.Parse(nmstr[0]);
var m = int.Parse(nmstr[1]);
var demand = new Demand[m];
for (int i = 0; i < m; i++) {
var abstr = Console.ReadLine().Split(' ');
var a = int.Parse(abstr[0]);
var b = int.Parse(abstr[1]);
demand[i] = new Demand(a, b);
}
demand.OrderBy(a => a.a).ThenBy(a => a.b);
var ans = 1;
var minb = demand[0].b;
for (int i = 1; i < m; i++) {
if (demand[i].a != demand[i - 1].a) {
if (demand[i].a >= minb) {
ans++;
minb = demand[i].b;
}
}
minb = Math.Min(minb, demand[i].b);
}
Console.WriteLine("{0}", ans);
}
}
|
using System;
using System.Linq;
struct Demand {
public int a;
public int b;
public Demand(int a, int b) {
this.a = a;
this.b = b;
}
}
class Program {
static void Main(string[] args) {
var nmstr = Console.ReadLine().Split(' ');
var n = int.Parse(nmstr[0]);
var m = int.Parse(nmstr[1]);
var demand = new Demand[m];
for (int i = 0; i < m; i++) {
var abstr = Console.ReadLine().Split(' ');
var a = int.Parse(abstr[0]);
var b = int.Parse(abstr[1]);
demand[i] = new Demand(a, b);
}
demand = demand.OrderBy(a => a.a).ThenBy(a => a.b).ToArray();
var ans = 1;
var minb = demand[0].b;
for (int i = 1; i < m; i++) {
if (demand[i].a != demand[i - 1].a) {
if (demand[i].a >= minb) {
ans++;
minb = demand[i].b;
}
}
minb = Math.Min(minb, demand[i].b);
}
Console.WriteLine("{0}", ans);
}
}
|
[["+", 8, 196, 0, 1, 0, 11, 0, 202, 0, 32], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 205, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 0, 131], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 3, 4, 0, 24]]
| 8
| 303
| 6
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace V {
partial class Solver {
public void Solve() {
var t = Read;
for (var i = 0; i < t; i++) {
YesNo(Slv(new Query { initial = Read, buy = Read, threshold = Read,
add = Read }));
}
}
bool Slv(Query q) {
if (q.initial < q.buy)
return false;
if (q.buy > q.add)
return false;
if (q.buy == q.add) {
var rem = q.initial % q.buy;
return rem <= q.threshold;
}
if (q.threshold >= q.buy) {
return true;
// return q.initial >= q.buy;
}
var min = q.threshold - q.buy;
var max = min + q.add;
var gcd = C.Gcd(q.buy, q.add);
var first = q.initial % q.buy;
var diff = first - min;
var final = first - diff / gcd * gcd;
return final >= 0;
}
public class Query {
public long initial;
public long buy;
public long threshold;
public long add;
}
}
}
namespace V {
class StartingPoint {
static void Main(string[] args) {
try {
var streamReader = args.Any()
? new StreamReader(args[0])
: new StreamReader(Console.OpenStandardInput());
var streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var scanner = new Scanner(streamReader);
var printer = new Printer(streamWriter);
var solver = new Solver(scanner, printer);
solver.Solve();
streamWriter.Flush();
} catch (Exception e) {
Console.WriteLine(e);
if (args.Any() == false)
throw e;
}
if (args.Any())
Console.ReadKey();
}
}
}
namespace V {
partial class Solver {
public Solver(Scanner sc, Printer pr) {
this.sc = sc;
this.pr = pr;
}
private readonly Scanner sc;
private readonly Printer pr;
private IEnumerable<int> Loop(int n) => C.Loop(n);
private IEnumerable<long> Loop(long n) => C.Loop(n);
private int RdInt => sc.Int;
private int ReadInt => sc.Int;
private long Rd => sc.Long;
private long Read => sc.Long;
private long ReadLong => sc.Long;
private double RdDouble => sc.Double;
private double ReadDouble => sc.Double;
private string Str => sc.Str;
private string RdStr => sc.Str;
private string ReadStr => sc.Str;
private int[] ArrInt(int n) => sc.Ints(n);
private int[] ArrInt(long n) => sc.Ints(n);
private long[] Arr(int n) => sc.Longs(n);
private long[] Arr(long n) => sc.Longs(n);
private long[] ArrLong(int n) => sc.Longs(n);
private long[] ArrLong(long n) => sc.Longs(n);
private double[] ArrDouble(int n) => sc.Doubles(n);
private double[] ArrDouble(long n) => sc.Doubles(n);
private string[] ArrStr(int n) => sc.Strs(n);
private string[] ArrStr(long n) => sc.Strs(n);
private void Wr(string s) => pr.Write(s);
private void Wr(object obj) => pr.Write(obj);
private void Wr<T>(IEnumerable<T> ts) => pr.Write(ts);
private void Wr(params object[] objs) => pr.Write(objs);
private void Write(string s) => pr.Write(s);
private void Write(object obj) => pr.Write(obj);
private void Write<T>(IEnumerable<T> ts) => pr.Write(ts);
private void Write(params object[] objs) => pr.Write(objs);
private void YesNo(bool b) => Write(b ? "Yes" : "No");
private void YESNO(bool b) => Write(b ? "YES" : "NO");
}
class Scanner {
private readonly TextReader reader;
public Scanner(TextReader reader) { this.reader = reader; }
private Queue<string> strQueue = new Queue<string>();
public string Str {
get {
if (strQueue.Count > 0)
return strQueue.Dequeue();
string[] strs = null;
do {
strs = reader.ReadLine().Split(new[] { ' ' },
StringSplitOptions.RemoveEmptyEntries);
} while (strs.Any() == false);
foreach (var s in strs.Skip(1))
strQueue.Enqueue(s);
return strs[0];
}
}
public int Int => int.Parse(this.Str);
public long Long => long.Parse(this.Str);
public double Double => double.Parse(this.Str);
public static bool TypeEquals<T1, T2>() => typeof(T1).Equals(typeof(T2));
public static T1
ChangeTypes<T1, T2>(T2 t2) => (T1)System.Convert.ChangeType(t2, typeof(T1));
public static T1 Convert<T1>(string s) =>
TypeEquals<T1, int>() ? ChangeTypes<T1, int>(int.Parse(s))
: TypeEquals<T1, long>() ? ChangeTypes<T1, long>(long.Parse(s))
: TypeEquals<T1, double>() ? ChangeTypes<T1, double>(int.Parse(s))
: TypeEquals<T1, char>() ? ChangeTypes<T1, char>(s[0])
: ChangeTypes<T1, string>(s);
public Pair<TX, TY> P2<TX, TY>() => new Pair<TX, TY>(Convert<TX>(this.Str),
Convert<TY>(this.Str));
public Pair3<TX, TY, TZ> P3<TX, TY, TZ>() => new Pair3<TX, TY, TZ>(
Convert<TX>(this.Str), Convert<TY>(this.Str), Convert<TZ>(this.Str));
public Pair4<TX, TY, TZ, TW> P4<TX, TY, TZ, TW>() =>
new Pair4<TX, TY, TZ, TW>(Convert<TX>(this.Str), Convert<TY>(this.Str),
Convert<TZ>(this.Str), Convert<TW>(this.Str));
}
static class ScannerExtension {
public static int[] Ints(this Scanner scanner,
int n) => scanner.Ints((long)n);
public static int[] Ints(this Scanner scanner,
long n) => scanner.ScanStrs<int>(n).ToArray();
public static long[] Longs(this Scanner scanner,
int n) => scanner.Longs((long)n);
public static long[] Longs(this Scanner scanner,
long n) => scanner.ScanStrs<long>(n).ToArray();
public static double[] Doubles(this Scanner scanner,
int n) => scanner.Doubles((long)n);
public static double[] Doubles(this Scanner scanner, long n) =>
scanner.ScanStrs<double>(n).ToArray();
public static string[] Strs(this Scanner scanner,
int n) => scanner.Strs((long)n);
public static string[] Strs(this Scanner scanner,
long n) => scanner.ScanStrs<string>(n).ToArray();
private static IEnumerable<T> ScanStrs<T>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return Scanner.Convert<T>(scanner.Str);
}
public static Pair<TX, TY>[] Pairs<TX, TY>(this Scanner scanner, int n) =>
scanner.Pairs<TX, TY>((long)n);
public static Pair<TX, TY>[] Pairs<TX, TY>(this Scanner scanner, long n) =>
scanner.ScanPairs<TX, TY>(n).ToArray();
public static Pair<long, long>[] Pairs(this Scanner scanner,
int n) => scanner.Pairs((long)n);
public static Pair<long, long>[] Pairs(this Scanner scanner, long n) =>
scanner.ScanPairs<long, long>(n).ToArray();
public static Pair<int, int>[] PairsInt(this Scanner scanner,
int n) => scanner.PairsInt((long)n);
public static Pair<int, int>[] PairsInt(this Scanner scanner, long n) =>
scanner.ScanPairs<int, int>(n).ToArray();
private static IEnumerable<Pair<TX, TY>>
ScanPairs<TX, TY>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return scanner.P2<TX, TY>();
}
public static Pair3<TX, TY, TZ>[] Pairs3<TX, TY, TZ>(
this Scanner scanner, int n) => scanner.Pairs3<TX, TY, TZ>((long)n);
public static Pair3<TX, TY, TZ>[] Pairs3<TX, TY, TZ>(this Scanner scanner,
long n) =>
scanner.ScanPairs3<TX, TY, TZ>(n).ToArray();
public static Pair3<long, long, long>[] Pairs3(this Scanner scanner, int n) =>
scanner.Pairs3((long)n);
public static Pair3<long, long, long>[] Pairs3(this Scanner scanner,
long n) =>
scanner.ScanPairs3<long, long, long>(n).ToArray();
public static Pair3<int, int, int>[] Pairs3Int(this Scanner scanner, int n) =>
scanner.Pairs3Int((long)n);
public static Pair3<int, int, int>[] Pairs3Int(this Scanner scanner,
long n) =>
scanner.ScanPairs3<int, int, int>(n).ToArray();
private static IEnumerable<Pair3<TX, TY, TZ>>
ScanPairs3<TX, TY, TZ>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return scanner.P3<TX, TY, TZ>();
}
public static Pair4<TX, TY, TZ, TW>[] Pairs4<TX, TY, TZ, TW>(
this Scanner scanner, int n) => scanner.Pairs4<TX, TY, TZ, TW>((long)n);
public static Pair4<TX, TY, TZ, TW>[] Pairs4<TX, TY, TZ, TW>(
this Scanner scanner,
long n) => scanner.ScanPairs4<TX, TY, TZ, TW>(n).ToArray();
public static Pair4<long, long, long, long>[] Pairs4(
this Scanner scanner, int n) => scanner.Pairs4((long)n);
public static Pair4<long, long, long, long>[] Pairs4(this Scanner scanner,
long n) =>
scanner.ScanPairs4<long, long, long, long>(n).ToArray();
public static Pair4<int, int, int, int>[] Pairs4Int(
this Scanner scanner, int n) => scanner.Pairs4Int((long)n);
public static Pair4<int, int, int, int>[] Pairs4Int(this Scanner scanner,
long n) =>
scanner.ScanPairs4<int, int, int, int>(n).ToArray();
private static IEnumerable<Pair4<TX, TY, TZ, TW>>
ScanPairs4<TX, TY, TZ, TW>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return scanner.P4<TX, TY, TZ, TW>();
}
}
class Pair<TX, TY> {
public TX X { get; }
public TY Y { get; }
public Pair(TX x, TY y) {
this.X = x;
this.Y = y;
}
}
class Pair : Pair<long, long> {
public Pair(long x, long y) : base(x, y) {}
}
class PairInt : Pair<int, int> {
public PairInt(int x, int y) : base(x, y) {}
}
class Pair3<TX, TY, TZ> {
public TX X { get; }
public TY Y { get; }
public TZ Z { get; }
public Pair3(TX x, TY y, TZ z) {
this.X = x;
this.Y = y;
this.Z = z;
}
}
class Pair3 : Pair3<long, long, long> {
public Pair3(long x, long y, long z) : base(x, y, z) {}
}
class Pair3Int : Pair3<int, int, int> {
public Pair3Int(int x, int y, int z) : base(x, y, z) {}
}
class Pair4<TX, TY, TZ, TW> {
public TX X { get; }
public TY Y { get; }
public TZ Z { get; }
public TW W { get; }
public Pair4(TX x, TY y, TZ z, TW w) {
this.X = x;
this.Y = y;
this.Z = z;
this.W = w;
}
}
class Pair4 : Pair4<long, long, long, long> {
public Pair4(long x, long y, long z, long w) : base(x, y, z, w) {}
}
class Pair4Int : Pair4<int, int, int, int> {
public Pair4Int(int x, int y, int z, int w) : base(x, y, z, w) {}
}
class Printer {
private readonly TextWriter writer;
public Printer(TextWriter writer) { this.writer = writer; }
public void Write(string obj) { writer.WriteLine(obj); }
public void Write(object obj) { writer.WriteLine(obj); }
public void Write<T>(IEnumerable<T> ts) {
writer.WriteLine(string.Join(" ", ts));
}
public void Write(params object[] objs) {
writer.WriteLine(string.Join(" ", objs));
}
}
static class Extension {
public static bool TryRemove<T>(this HashSet<T> ts, T t) {
if (ts.Contains(t)) {
ts.Remove(t);
return true;
} else {
return false;
}
}
public static void SafeSet<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] = value;
else
ts.Add(t, value);
}
public static void SafeAdd<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] += value;
else
ts.Add(t, value);
}
public static void SafeSub<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] -= value;
else
ts.Add(t, value);
}
public static void SafeMult<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] *= value;
else
ts.Add(t, value);
}
public static void SafeDiv<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] /= value;
else
ts.Add(t, value);
}
public static HashSet<T>
ToHashSet<T>(this IEnumerable<T> ts) => new HashSet<T>(ts.Distinct());
public static long ToDigit(this char c) => (long)(c - '0');
public static long ToSmallAbcIndex(this char c) => (long)(c - 'a');
public static long ToLargeAbcIndex(this char c) => (long)(c - 'A');
public static long Count<T1, T2>(this IGrouping<T1, T2> gs) => gs.LongCount();
}
class C {
public class IterTools {
/// <summary>
/// 組み合わせ(重複なし)
/// n = 4, k = 3 => (0,1,2) (0,1,3) (0,2,3) (1,2,3)
/// </summary>
public static IEnumerable<IReadOnlyList<long>> Combinations(long n,
long k) {
if (k <= 0)
yield break;
long[] indices = new long[k];
long pointer = 0;
while (pointer >= 0) {
if (indices[pointer] < n) {
if (pointer >= k - 1) {
yield return indices;
indices[pointer]++;
} else {
indices[pointer + 1] = indices[pointer] + 1;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
indices[pointer]++;
}
}
}
/// <summary>
/// 組み合わせ(重複なし)
/// n = 4, k = 3 => (0,1,2) (0,1,3) (0,2,3) (1,2,3)
/// </summary>
public static IEnumerable<IReadOnlyList<T>> Combinations<T>(T[] ts,
long k) {
if (k <= 0)
yield break;
long[] indices = new long[k];
T[] container = new T[k];
long pointer = 0;
long n = ts.LongLength;
while (pointer >= 0) {
if (indices[pointer] < n) {
container[pointer] = ts[indices[pointer]];
if (pointer >= k - 1) {
yield return container;
indices[pointer]++;
} else {
indices[pointer + 1] = indices[pointer] + 1;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
indices[pointer]++;
}
}
}
/// <summary>
/// 組み合わせ(重複あり)
/// n = 3, k = 2 => (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
/// </summary>
public static IEnumerable<IReadOnlyList<long>>
CombinationsWithReplacement(long n, long k) {
if (k <= 0)
yield break;
long[] container = new long[k];
long pointer = 0;
while (pointer >= 0) {
if (container[pointer] < n) {
if (pointer >= k - 1) {
yield return container;
container[pointer]++;
} else {
container[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
container[pointer]++;
}
}
}
/// <summary>
/// 組み合わせ(重複あり)
/// n = 3, k = 2 => (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
/// </summary>
public static IEnumerable<IReadOnlyList<T>>
CombinationsWithReplacement<T>(T[] ts, long k) {
if (k <= 0)
yield break;
long[] indices = new long[k];
T[] container = new T[k];
long pointer = 0;
long n = ts.LongLength;
while (pointer >= 0) {
if (indices[pointer] < n) {
container[pointer] = ts[indices[pointer]];
if (pointer >= k - 1) {
yield return container;
indices[pointer]++;
} else {
indices[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
indices[pointer]++;
}
}
}
/// <summary>
/// 順列
/// n = 3, k = 2 => (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)
/// </summary>
public static IEnumerable<IReadOnlyList<long>> Permutations(long n,
long k) {
if (k <= 0)
yield break;
HashSet<long> enumed = new HashSet<long>();
long[] container = new long[k];
long pointer = 0;
while (pointer >= 0) {
if (container[pointer] < n) {
if (enumed.Contains(container[pointer])) {
container[pointer]++;
} else if (pointer >= k - 1) {
yield return container;
container[pointer]++;
} else {
enumed.Add(container[pointer]);
container[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0) {
enumed.Remove(container[pointer]);
container[pointer]++;
}
}
}
}
/// <summary>
/// 順列
/// n = 3, k = 2 => (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)
/// </summary>
public static IEnumerable<IReadOnlyList<T>> Permutations<T>(T[] ts,
long k) {
if (k <= 0)
yield break;
HashSet<long> enumed = new HashSet<long>();
long[] indices = new long[k];
T[] container = new T[k];
long pointer = 0;
long n = ts.LongLength;
while (pointer >= 0) {
if (indices[pointer] < n) {
if (enumed.Contains(indices[pointer])) {
indices[pointer]++;
} else if (pointer >= k - 1) {
container[pointer] = ts[indices[pointer]];
yield return container;
indices[pointer]++;
} else {
container[pointer] = ts[indices[pointer]];
enumed.Add(indices[pointer]);
indices[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0) {
enumed.Remove(indices[pointer]);
indices[pointer]++;
}
}
}
}
}
public class Tree {
public Tree() { toNodes = new Dictionary<long, long[]>(); }
public Tree(Scanner sc, long n, bool base1 = true,
bool singleDirection = false) {
Adjust(sc.Pairs(n), base1, singleDirection);
}
public Tree(Pair<long, long>[] edges, bool base1 = true,
bool singleDirection = false) {
Adjust(edges, base1, singleDirection);
}
public Tree(IEnumerable<long> ps, IEnumerable<long> qs, bool base1 = true,
bool singleDirection = false) {
Adjust(ps.Zip(qs, (p, q) => new Pair<long, long>(p, q)).ToArray(), base1,
singleDirection);
}
private void Adjust(Pair<long, long>[] edges, bool base1,
bool singleDirection) {
var arrows = base1
? edges.Select(x => new { from = x.X - 1, to = x.Y - 1 })
: edges.Select(x => new { from = x.X, to = x.Y });
if (singleDirection == false)
arrows =
arrows.Concat(arrows.Select(x => new { from = x.to, to = x.from }));
toNodes =
arrows.GroupBy(x => x.from)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.to).ToArray());
}
private long[] empty = new long[0];
private Dictionary<long, long[]> toNodes;
public long[] To(long from) {
long[] res = null;
if (toNodes.TryGetValue(from, out res))
return res;
else
return empty;
}
public IEnumerable<Pair<long, long>> GetRouteEdges(long from, long to) {
return GetRouteEdgesImpl(from, to).Skip(1);
}
private IEnumerable<Pair<long, long>> GetRouteEdgesImpl(long from,
long to) {
var routeNodes = GetRouteNodes(from, to);
var current = -1L;
foreach (var next in routeNodes) {
yield return new Pair<long, long>(current, next);
current = next;
}
}
public IEnumerable<long> GetRouteNodes(long from, long to) {
Stack<long> routeNodes = new Stack<long>();
HashSet<long> checkedNodes = new HashSet<long>();
GetRouteNodes(from, to, routeNodes, checkedNodes);
return routeNodes.Reverse();
}
private bool GetRouteNodes(long current, long dest, Stack<long> routeNodes,
HashSet<long> checkedNodes) {
routeNodes.Push(current);
checkedNodes.Add(current);
if (current == dest)
return true;
foreach (var next in toNodes[current]) {
if (checkedNodes.Contains(next))
continue;
if (GetRouteNodes(next, dest, routeNodes, checkedNodes))
return true;
}
routeNodes.Pop();
return false;
}
}
public class PriorityQueue<TKey, TState>
where TKey : IComparable<TKey> {
public int Count { get; private set; }
private readonly Func<TState, TKey> keySelector;
private readonly bool desc;
private TState[] states = new TState[65536];
private TKey[] keys = new TKey[65536];
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PriorityQueue(Func<TState, TKey> keySelector, bool desc = false) {
this.keySelector = keySelector;
this.desc = desc;
}
public TState Top {
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
get {
ValidateNonEmpty();
return states[1];
}
}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TState Dequeue() {
var top = Top;
var item = states[Count];
var key = keys[Count];
Count--;
int index = 1;
while (true) {
if ((index << 1) >= Count) {
if (index << 1 > Count)
break;
if (key.CompareTo(keys[index << 1]) <= 0 ^ desc)
break;
states[index] = states[index << 1];
keys[index] = keys[index << 1];
index <<= 1;
} else {
var nextIndex =
keys[index << 1].CompareTo(keys[(index << 1) + 1]) <= 0 ^ desc
? (index << 1)
: (index << 1) + 1;
if (key.CompareTo(keys[nextIndex]) <= 0 ^ desc)
break;
states[index] = states[nextIndex];
keys[index] = keys[nextIndex];
index = nextIndex;
}
}
states[index] = item;
keys[index] = key;
return top;
}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(TState state) {
var key = keySelector.Invoke(state);
Count++;
int index = Count;
if (states.Length == Count)
Extend(states.Length * 2);
while ((index >> 1) != 0) {
if (keys[index >> 1].CompareTo(key) <= 0 ^ desc)
break;
states[index] = states[index >> 1];
keys[index] = keys[index >> 1];
index >>= 1;
}
states[index] = state;
keys[index] = key;
}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Extend(int newSize) {
TState[] newStates = new TState[newSize];
TKey[] newKeys = new TKey[newSize];
states.CopyTo(newStates, 0);
keys.CopyTo(newKeys, 0);
states = newStates;
keys = newKeys;
}
private void ValidateNonEmpty() {
if (Count == 0)
throw new IndexOutOfRangeException();
}
}
public class BinaryIndexTree {
long length;
long[] binaryIndexedTree;
public BinaryIndexTree(long length) {
this.length = length;
binaryIndexedTree = new long[length + 1];
}
public void Add(long indexZeroBase, long additional) {
// i += i & -i
// 1が立っている最下位ビットを足す、の意味
for (long i = indexZeroBase + 1; i <= length; i += i & -i) {
binaryIndexedTree[i] += additional;
}
}
public long Sum(long indexZeroBase) {
long result = 0;
// i += i & -i
// 1が立っている最下位ビットを引く、の意味
for (long i = indexZeroBase + 1; i > 0; i -= i & -i) {
result += binaryIndexedTree[i];
}
return result;
}
}
public static class BinarySearch {
public static long GetFirstIndexGreater<T>(T x, IList<T> listOrdered)
where T : IComparable {
return GetFirstIndexGreater(x, listOrdered, 0, listOrdered.Count - 1);
}
public static long GetFirstIndexGreater<T>(T x, IList<T> listOrdered,
int low, int high)
where T : IComparable {
var count = listOrdered.Count;
if (count == 0)
return low;
if (listOrdered[high].CompareTo(x) <= 0)
return high + 1;
while (low < high) {
var mid = (low + high) / 2;
if (listOrdered[mid].CompareTo(x) > 0)
high = mid;
else
low = mid + 1;
}
return low;
}
public static long GetLastIndexLess<T>(T x, IList<T> listOrdered)
where T : IComparable {
return GetLastIndexLess(x, listOrdered, 0, listOrdered.Count - 1);
}
public static long GetLastIndexLess<T>(T x, IList<T> listOrdered, int low,
int high)
where T : IComparable {
var count = listOrdered.Count;
if (count == 0)
return low - 1;
if (listOrdered[0].CompareTo(x) >= 0)
return low - 1;
while (low < high) {
var mid = (low + high + 1) / 2;
if (listOrdered[mid].CompareTo(x) < 0)
low = mid;
else
high = mid - 1;
}
return low;
}
}
public static class BellmanFord {
public class Vertex {
public long Distance { get; set; }
public Vertex() { Distance = long.MaxValue; }
}
public class Edge {
public int From { get; private set; }
public int To { get; private set; }
public long Weight { get; private set; }
public Edge(int from, int to, long weight) {
From = from;
To = to;
Weight = weight;
}
}
private static void GetReachable(int origin, ref HashSet<int> reached,
ref Dictionary<int, int[]> paths) {
if (reached.Contains(origin))
return;
reached.Add(origin);
if (paths.ContainsKey(origin) == false)
return;
foreach (var p in paths[origin])
GetReachable(p, ref reached, ref paths);
}
/// <summary>
/// null: 負の無限大
/// long.MaxValue: たどり着けない
/// その他: 距離
/// </summary>
public static long? RunBellmanFord(int vertexCount, List<Edge> rawEdges,
int source, int dest) {
var forwards =
rawEdges.GroupBy(x => x.From)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.To).ToArray());
var reverses = rawEdges.GroupBy(x => x.To).ToDictionary(
x => x.Key, x => x.Select(xs => xs.From).ToArray());
var fromSource = new HashSet<int>();
var toDest = new HashSet<int>();
GetReachable(source, ref fromSource, ref forwards);
GetReachable(dest, ref toDest, ref reverses);
var edges = rawEdges.Where(e => fromSource.Contains(e.From))
.Where(e => fromSource.Contains(e.To))
.Where(e => toDest.Contains(e.From))
.Where(e => toDest.Contains(e.To))
.ToArray();
// initialize distances
var vertices = new List<Vertex>();
for (int i = 0; i < vertexCount; i++)
vertices.Add(new Vertex());
vertices[source].Distance = 0L;
// update distances
for (int i = 0; i < vertices.Count; i++) {
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance == long.MaxValue)
continue;
var newDistance = from.Distance + e.Weight;
if (to.Distance > newDistance) {
to.Distance = newDistance;
}
}
}
// check negative cycle
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance + e.Weight < to.Distance)
return null;
}
return vertices[dest].Distance;
}
}
public static long Gcd(int a, int b) => Gcd((long)a, (long)b);
public static long Gcd(long a, long b) {
if (a < b)
return GcdImpl(b, a);
else
return GcdImpl(a, b);
}
private static long GcdImpl(long a, long b) {
var remainder = a % b;
if (remainder == 0)
return b;
else
return GcdImpl(b, remainder);
}
public static long Lcm(int a, int b) => Lcm((long)a, (long)b);
public static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
public static long Pow(int n, int p) => Pow((long)n, (long)p);
public static long Pow(long n, long p) {
var res = 1L;
for (long i = 0; i < p; i++)
res *= n;
return res;
}
public static Dictionary<long, long> Factorize(int n) => Factorize((long)n);
public static Dictionary<long, long> Factorize(long n) {
var res = new Dictionary<long, long>();
var r = n;
for (long i = 2; i * i <= r; i++) {
var c = 0L;
while (r % i == 0) {
c++;
r /= i;
}
if (c > 0)
res.Add(i, c);
}
if (r > 1)
res.Add(r, 1);
return res;
}
public static IEnumerable<long> Divisors(int n) => Divisors((long)n);
public static IEnumerable<long> Divisors(long n) {
var cache = new Stack<long>();
for (long i = 1; i * i <= n; i++) {
if (n % i == 0) {
yield return i;
cache.Push(i);
}
}
var r = cache.Peek();
if (r * r == n)
cache.Pop();
while (cache.Count > 0) {
var i = cache.Pop();
yield return n / i;
}
}
public static IEnumerable<int> Loop(int n) {
for (int i = 0; i < n; i++)
yield return i;
}
public static IEnumerable<long> Loop(long n) {
for (long i = 0L; i < n; i++)
yield return i;
}
}
struct Mint {
public static long Divider {
set { divider = value; }
}
private static long divider = 1000000007L;
public static void Set998244353() { divider = 998244353L; }
public static void Set1000000009() { divider = 1000000009L; }
public long Value { get; }
public override string ToString() => this.Value.ToString();
public Mint(long value) { this.Value = value; }
// public static implicit operator Mint(long a) => new Mint(a % divider);
// public static implicit operator Mint(int a) => new Mint(a % divider);
// public static explicit operator long(Mint a) => a.Value;
// public static explicit operator int(Mint a) => (int)a.Value;
public static Mint
operator +(Mint a, Mint b) => new Mint((a.Value + b.Value) % divider);
public static Mint operator +(Mint a, long b) => a + new Mint(b);
public static Mint operator +(Mint a, int b) => a + new Mint(b);
public static Mint operator -(Mint a, Mint b) {
var t = (a.Value - b.Value) % divider;
if (t < 0L)
t += divider;
return new Mint(t);
}
public static Mint operator -(Mint a, long b) => a - new Mint(b);
public static Mint operator -(Mint a, int b) => a - new Mint(b);
public static Mint
operator *(Mint a, Mint b) => new Mint((a.Value * b.Value) % divider);
public static Mint operator *(Mint a, long b) => a * new Mint(b);
public static Mint operator *(Mint a, int b) => a * new Mint(b);
public static Mint operator /(Mint a, Mint b) =>
new Mint((a.Value * InvImpl(b.Value)) % divider);
public static Mint operator /(Mint a, long b) => a / new Mint(b);
public static Mint operator /(Mint a, int b) => a / new Mint(b);
public Mint Pow(long p) => new Mint(PowImpl(Value, p));
public static Mint Pow(long a, long p) => new Mint(PowImpl(a, p));
private static long PowImpl(long a, long p) {
if (p == 0L)
return 1L;
if (p == 1L)
return a;
var halfP = p / 2L;
var halfPowered = PowImpl(a, halfP);
var powered = halfPowered * halfPowered % divider;
return p % 2L == 0L ? powered : powered * a % divider;
}
public static Mint Inv(long a) => new Mint(InvImpl(a));
private static readonly Dictionary<long, long> invCache =
new Dictionary<long, long>();
private static long InvImpl(long a) {
long cache;
if (invCache.TryGetValue(a, out cache))
return cache;
var result = PowImpl(a, divider - 2L);
invCache.Add(a, result);
return result;
}
public static Mint Fac(long a) => new Mint(FacImpl(a));
private static long[] facCache = new long[262144];
private static long cachedFac = 0L;
private static long FacImpl(long a) {
if (a >= divider)
return 0L;
facCache[0] = 1L;
if (facCache.LongLength <= a) {
long newSize = facCache.LongLength;
while (newSize <= a) {
newSize *= 2;
}
ExtendFacCache(newSize);
}
if (cachedFac < a) {
var val = facCache[cachedFac];
var start = cachedFac + 1L;
for (long i = start; i <= a; i++) {
val = (val * i) % divider;
facCache[i] = val;
}
cachedFac = a;
}
return facCache[a];
}
private static void ExtendFacCache(long newSize) {
long[] newFacCache = new long[newSize];
facCache.CopyTo(newFacCache, 0);
facCache = newFacCache;
}
public static Mint Perm(long n, long r) => new Mint(PermImpl(n, r));
private static long PermImpl(long n, long r) {
if (n < r)
return 0L;
if (r <= 0L)
return 1L;
var nn = FacImpl(n);
var nr = FacImpl(n - r);
return (nn * InvImpl(nr)) % divider;
}
public static Mint Comb(long n, long r) => new Mint(CombImpl(n, r));
private static long CombImpl(long n, long r) {
if (n < r)
return 0L;
if (n == r)
return 1L;
if (n - r < r)
return CombImpl(n, n - r);
var nn = FacImpl(n);
var nr = FacImpl(n - r);
var rr = FacImpl(r);
var nrrr = (nr * rr) % divider;
return (nn * InvImpl(nrrr)) % divider;
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace V {
partial class Solver {
public void Solve() {
var t = Read;
for (var i = 0; i < t; i++) {
YesNo(Slv(new Query { initial = Read, buy = Read, threshold = Read,
add = Read }));
}
}
bool Slv(Query q) {
if (q.initial < q.buy)
return false;
if (q.buy > q.add)
return false;
if (q.buy == q.add) {
var rem = q.initial % q.buy;
return rem <= q.threshold;
}
if (q.threshold >= q.buy) {
return true;
// return q.initial >= q.buy;
}
var min = q.threshold + 1 - q.buy;
var max = min + q.add;
var gcd = C.Gcd(q.buy, q.add);
var first = q.initial % q.buy;
var diff = first - min;
var final = first - diff / gcd * gcd;
return final >= 0;
}
public class Query {
public long initial;
public long buy;
public long threshold;
public long add;
}
}
}
namespace V {
class StartingPoint {
static void Main(string[] args) {
try {
var streamReader = args.Any()
? new StreamReader(args[0])
: new StreamReader(Console.OpenStandardInput());
var streamWriter =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
var scanner = new Scanner(streamReader);
var printer = new Printer(streamWriter);
var solver = new Solver(scanner, printer);
solver.Solve();
streamWriter.Flush();
} catch (Exception e) {
Console.WriteLine(e);
if (args.Any() == false)
throw e;
}
if (args.Any())
Console.ReadKey();
}
}
}
namespace V {
partial class Solver {
public Solver(Scanner sc, Printer pr) {
this.sc = sc;
this.pr = pr;
}
private readonly Scanner sc;
private readonly Printer pr;
private IEnumerable<int> Loop(int n) => C.Loop(n);
private IEnumerable<long> Loop(long n) => C.Loop(n);
private int RdInt => sc.Int;
private int ReadInt => sc.Int;
private long Rd => sc.Long;
private long Read => sc.Long;
private long ReadLong => sc.Long;
private double RdDouble => sc.Double;
private double ReadDouble => sc.Double;
private string Str => sc.Str;
private string RdStr => sc.Str;
private string ReadStr => sc.Str;
private int[] ArrInt(int n) => sc.Ints(n);
private int[] ArrInt(long n) => sc.Ints(n);
private long[] Arr(int n) => sc.Longs(n);
private long[] Arr(long n) => sc.Longs(n);
private long[] ArrLong(int n) => sc.Longs(n);
private long[] ArrLong(long n) => sc.Longs(n);
private double[] ArrDouble(int n) => sc.Doubles(n);
private double[] ArrDouble(long n) => sc.Doubles(n);
private string[] ArrStr(int n) => sc.Strs(n);
private string[] ArrStr(long n) => sc.Strs(n);
private void Wr(string s) => pr.Write(s);
private void Wr(object obj) => pr.Write(obj);
private void Wr<T>(IEnumerable<T> ts) => pr.Write(ts);
private void Wr(params object[] objs) => pr.Write(objs);
private void Write(string s) => pr.Write(s);
private void Write(object obj) => pr.Write(obj);
private void Write<T>(IEnumerable<T> ts) => pr.Write(ts);
private void Write(params object[] objs) => pr.Write(objs);
private void YesNo(bool b) => Write(b ? "Yes" : "No");
private void YESNO(bool b) => Write(b ? "YES" : "NO");
}
class Scanner {
private readonly TextReader reader;
public Scanner(TextReader reader) { this.reader = reader; }
private Queue<string> strQueue = new Queue<string>();
public string Str {
get {
if (strQueue.Count > 0)
return strQueue.Dequeue();
string[] strs = null;
do {
strs = reader.ReadLine().Split(new[] { ' ' },
StringSplitOptions.RemoveEmptyEntries);
} while (strs.Any() == false);
foreach (var s in strs.Skip(1))
strQueue.Enqueue(s);
return strs[0];
}
}
public int Int => int.Parse(this.Str);
public long Long => long.Parse(this.Str);
public double Double => double.Parse(this.Str);
public static bool TypeEquals<T1, T2>() => typeof(T1).Equals(typeof(T2));
public static T1
ChangeTypes<T1, T2>(T2 t2) => (T1)System.Convert.ChangeType(t2, typeof(T1));
public static T1 Convert<T1>(string s) =>
TypeEquals<T1, int>() ? ChangeTypes<T1, int>(int.Parse(s))
: TypeEquals<T1, long>() ? ChangeTypes<T1, long>(long.Parse(s))
: TypeEquals<T1, double>() ? ChangeTypes<T1, double>(int.Parse(s))
: TypeEquals<T1, char>() ? ChangeTypes<T1, char>(s[0])
: ChangeTypes<T1, string>(s);
public Pair<TX, TY> P2<TX, TY>() => new Pair<TX, TY>(Convert<TX>(this.Str),
Convert<TY>(this.Str));
public Pair3<TX, TY, TZ> P3<TX, TY, TZ>() => new Pair3<TX, TY, TZ>(
Convert<TX>(this.Str), Convert<TY>(this.Str), Convert<TZ>(this.Str));
public Pair4<TX, TY, TZ, TW> P4<TX, TY, TZ, TW>() =>
new Pair4<TX, TY, TZ, TW>(Convert<TX>(this.Str), Convert<TY>(this.Str),
Convert<TZ>(this.Str), Convert<TW>(this.Str));
}
static class ScannerExtension {
public static int[] Ints(this Scanner scanner,
int n) => scanner.Ints((long)n);
public static int[] Ints(this Scanner scanner,
long n) => scanner.ScanStrs<int>(n).ToArray();
public static long[] Longs(this Scanner scanner,
int n) => scanner.Longs((long)n);
public static long[] Longs(this Scanner scanner,
long n) => scanner.ScanStrs<long>(n).ToArray();
public static double[] Doubles(this Scanner scanner,
int n) => scanner.Doubles((long)n);
public static double[] Doubles(this Scanner scanner, long n) =>
scanner.ScanStrs<double>(n).ToArray();
public static string[] Strs(this Scanner scanner,
int n) => scanner.Strs((long)n);
public static string[] Strs(this Scanner scanner,
long n) => scanner.ScanStrs<string>(n).ToArray();
private static IEnumerable<T> ScanStrs<T>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return Scanner.Convert<T>(scanner.Str);
}
public static Pair<TX, TY>[] Pairs<TX, TY>(this Scanner scanner, int n) =>
scanner.Pairs<TX, TY>((long)n);
public static Pair<TX, TY>[] Pairs<TX, TY>(this Scanner scanner, long n) =>
scanner.ScanPairs<TX, TY>(n).ToArray();
public static Pair<long, long>[] Pairs(this Scanner scanner,
int n) => scanner.Pairs((long)n);
public static Pair<long, long>[] Pairs(this Scanner scanner, long n) =>
scanner.ScanPairs<long, long>(n).ToArray();
public static Pair<int, int>[] PairsInt(this Scanner scanner,
int n) => scanner.PairsInt((long)n);
public static Pair<int, int>[] PairsInt(this Scanner scanner, long n) =>
scanner.ScanPairs<int, int>(n).ToArray();
private static IEnumerable<Pair<TX, TY>>
ScanPairs<TX, TY>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return scanner.P2<TX, TY>();
}
public static Pair3<TX, TY, TZ>[] Pairs3<TX, TY, TZ>(
this Scanner scanner, int n) => scanner.Pairs3<TX, TY, TZ>((long)n);
public static Pair3<TX, TY, TZ>[] Pairs3<TX, TY, TZ>(this Scanner scanner,
long n) =>
scanner.ScanPairs3<TX, TY, TZ>(n).ToArray();
public static Pair3<long, long, long>[] Pairs3(this Scanner scanner, int n) =>
scanner.Pairs3((long)n);
public static Pair3<long, long, long>[] Pairs3(this Scanner scanner,
long n) =>
scanner.ScanPairs3<long, long, long>(n).ToArray();
public static Pair3<int, int, int>[] Pairs3Int(this Scanner scanner, int n) =>
scanner.Pairs3Int((long)n);
public static Pair3<int, int, int>[] Pairs3Int(this Scanner scanner,
long n) =>
scanner.ScanPairs3<int, int, int>(n).ToArray();
private static IEnumerable<Pair3<TX, TY, TZ>>
ScanPairs3<TX, TY, TZ>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return scanner.P3<TX, TY, TZ>();
}
public static Pair4<TX, TY, TZ, TW>[] Pairs4<TX, TY, TZ, TW>(
this Scanner scanner, int n) => scanner.Pairs4<TX, TY, TZ, TW>((long)n);
public static Pair4<TX, TY, TZ, TW>[] Pairs4<TX, TY, TZ, TW>(
this Scanner scanner,
long n) => scanner.ScanPairs4<TX, TY, TZ, TW>(n).ToArray();
public static Pair4<long, long, long, long>[] Pairs4(
this Scanner scanner, int n) => scanner.Pairs4((long)n);
public static Pair4<long, long, long, long>[] Pairs4(this Scanner scanner,
long n) =>
scanner.ScanPairs4<long, long, long, long>(n).ToArray();
public static Pair4<int, int, int, int>[] Pairs4Int(
this Scanner scanner, int n) => scanner.Pairs4Int((long)n);
public static Pair4<int, int, int, int>[] Pairs4Int(this Scanner scanner,
long n) =>
scanner.ScanPairs4<int, int, int, int>(n).ToArray();
private static IEnumerable<Pair4<TX, TY, TZ, TW>>
ScanPairs4<TX, TY, TZ, TW>(this Scanner scanner, long n) {
for (long i = 0; i < n; i++)
yield return scanner.P4<TX, TY, TZ, TW>();
}
}
class Pair<TX, TY> {
public TX X { get; }
public TY Y { get; }
public Pair(TX x, TY y) {
this.X = x;
this.Y = y;
}
}
class Pair : Pair<long, long> {
public Pair(long x, long y) : base(x, y) {}
}
class PairInt : Pair<int, int> {
public PairInt(int x, int y) : base(x, y) {}
}
class Pair3<TX, TY, TZ> {
public TX X { get; }
public TY Y { get; }
public TZ Z { get; }
public Pair3(TX x, TY y, TZ z) {
this.X = x;
this.Y = y;
this.Z = z;
}
}
class Pair3 : Pair3<long, long, long> {
public Pair3(long x, long y, long z) : base(x, y, z) {}
}
class Pair3Int : Pair3<int, int, int> {
public Pair3Int(int x, int y, int z) : base(x, y, z) {}
}
class Pair4<TX, TY, TZ, TW> {
public TX X { get; }
public TY Y { get; }
public TZ Z { get; }
public TW W { get; }
public Pair4(TX x, TY y, TZ z, TW w) {
this.X = x;
this.Y = y;
this.Z = z;
this.W = w;
}
}
class Pair4 : Pair4<long, long, long, long> {
public Pair4(long x, long y, long z, long w) : base(x, y, z, w) {}
}
class Pair4Int : Pair4<int, int, int, int> {
public Pair4Int(int x, int y, int z, int w) : base(x, y, z, w) {}
}
class Printer {
private readonly TextWriter writer;
public Printer(TextWriter writer) { this.writer = writer; }
public void Write(string obj) { writer.WriteLine(obj); }
public void Write(object obj) { writer.WriteLine(obj); }
public void Write<T>(IEnumerable<T> ts) {
writer.WriteLine(string.Join(" ", ts));
}
public void Write(params object[] objs) {
writer.WriteLine(string.Join(" ", objs));
}
}
static class Extension {
public static bool TryRemove<T>(this HashSet<T> ts, T t) {
if (ts.Contains(t)) {
ts.Remove(t);
return true;
} else {
return false;
}
}
public static void SafeSet<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] = value;
else
ts.Add(t, value);
}
public static void SafeAdd<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] += value;
else
ts.Add(t, value);
}
public static void SafeSub<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] -= value;
else
ts.Add(t, value);
}
public static void SafeMult<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] *= value;
else
ts.Add(t, value);
}
public static void SafeDiv<T>(this Dictionary<T, long> ts, T t, long value) {
if (ts.ContainsKey(t))
ts[t] /= value;
else
ts.Add(t, value);
}
public static HashSet<T>
ToHashSet<T>(this IEnumerable<T> ts) => new HashSet<T>(ts.Distinct());
public static long ToDigit(this char c) => (long)(c - '0');
public static long ToSmallAbcIndex(this char c) => (long)(c - 'a');
public static long ToLargeAbcIndex(this char c) => (long)(c - 'A');
public static long Count<T1, T2>(this IGrouping<T1, T2> gs) => gs.LongCount();
}
class C {
public class IterTools {
/// <summary>
/// 組み合わせ(重複なし)
/// n = 4, k = 3 => (0,1,2) (0,1,3) (0,2,3) (1,2,3)
/// </summary>
public static IEnumerable<IReadOnlyList<long>> Combinations(long n,
long k) {
if (k <= 0)
yield break;
long[] indices = new long[k];
long pointer = 0;
while (pointer >= 0) {
if (indices[pointer] < n) {
if (pointer >= k - 1) {
yield return indices;
indices[pointer]++;
} else {
indices[pointer + 1] = indices[pointer] + 1;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
indices[pointer]++;
}
}
}
/// <summary>
/// 組み合わせ(重複なし)
/// n = 4, k = 3 => (0,1,2) (0,1,3) (0,2,3) (1,2,3)
/// </summary>
public static IEnumerable<IReadOnlyList<T>> Combinations<T>(T[] ts,
long k) {
if (k <= 0)
yield break;
long[] indices = new long[k];
T[] container = new T[k];
long pointer = 0;
long n = ts.LongLength;
while (pointer >= 0) {
if (indices[pointer] < n) {
container[pointer] = ts[indices[pointer]];
if (pointer >= k - 1) {
yield return container;
indices[pointer]++;
} else {
indices[pointer + 1] = indices[pointer] + 1;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
indices[pointer]++;
}
}
}
/// <summary>
/// 組み合わせ(重複あり)
/// n = 3, k = 2 => (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
/// </summary>
public static IEnumerable<IReadOnlyList<long>>
CombinationsWithReplacement(long n, long k) {
if (k <= 0)
yield break;
long[] container = new long[k];
long pointer = 0;
while (pointer >= 0) {
if (container[pointer] < n) {
if (pointer >= k - 1) {
yield return container;
container[pointer]++;
} else {
container[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
container[pointer]++;
}
}
}
/// <summary>
/// 組み合わせ(重複あり)
/// n = 3, k = 2 => (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
/// </summary>
public static IEnumerable<IReadOnlyList<T>>
CombinationsWithReplacement<T>(T[] ts, long k) {
if (k <= 0)
yield break;
long[] indices = new long[k];
T[] container = new T[k];
long pointer = 0;
long n = ts.LongLength;
while (pointer >= 0) {
if (indices[pointer] < n) {
container[pointer] = ts[indices[pointer]];
if (pointer >= k - 1) {
yield return container;
indices[pointer]++;
} else {
indices[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0)
indices[pointer]++;
}
}
}
/// <summary>
/// 順列
/// n = 3, k = 2 => (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)
/// </summary>
public static IEnumerable<IReadOnlyList<long>> Permutations(long n,
long k) {
if (k <= 0)
yield break;
HashSet<long> enumed = new HashSet<long>();
long[] container = new long[k];
long pointer = 0;
while (pointer >= 0) {
if (container[pointer] < n) {
if (enumed.Contains(container[pointer])) {
container[pointer]++;
} else if (pointer >= k - 1) {
yield return container;
container[pointer]++;
} else {
enumed.Add(container[pointer]);
container[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0) {
enumed.Remove(container[pointer]);
container[pointer]++;
}
}
}
}
/// <summary>
/// 順列
/// n = 3, k = 2 => (0,1) (0,2) (1,0) (1,2) (2,0) (2,1)
/// </summary>
public static IEnumerable<IReadOnlyList<T>> Permutations<T>(T[] ts,
long k) {
if (k <= 0)
yield break;
HashSet<long> enumed = new HashSet<long>();
long[] indices = new long[k];
T[] container = new T[k];
long pointer = 0;
long n = ts.LongLength;
while (pointer >= 0) {
if (indices[pointer] < n) {
if (enumed.Contains(indices[pointer])) {
indices[pointer]++;
} else if (pointer >= k - 1) {
container[pointer] = ts[indices[pointer]];
yield return container;
indices[pointer]++;
} else {
container[pointer] = ts[indices[pointer]];
enumed.Add(indices[pointer]);
indices[pointer + 1] = 0;
pointer++;
}
} else {
pointer--;
if (pointer >= 0) {
enumed.Remove(indices[pointer]);
indices[pointer]++;
}
}
}
}
}
public class Tree {
public Tree() { toNodes = new Dictionary<long, long[]>(); }
public Tree(Scanner sc, long n, bool base1 = true,
bool singleDirection = false) {
Adjust(sc.Pairs(n), base1, singleDirection);
}
public Tree(Pair<long, long>[] edges, bool base1 = true,
bool singleDirection = false) {
Adjust(edges, base1, singleDirection);
}
public Tree(IEnumerable<long> ps, IEnumerable<long> qs, bool base1 = true,
bool singleDirection = false) {
Adjust(ps.Zip(qs, (p, q) => new Pair<long, long>(p, q)).ToArray(), base1,
singleDirection);
}
private void Adjust(Pair<long, long>[] edges, bool base1,
bool singleDirection) {
var arrows = base1
? edges.Select(x => new { from = x.X - 1, to = x.Y - 1 })
: edges.Select(x => new { from = x.X, to = x.Y });
if (singleDirection == false)
arrows =
arrows.Concat(arrows.Select(x => new { from = x.to, to = x.from }));
toNodes =
arrows.GroupBy(x => x.from)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.to).ToArray());
}
private long[] empty = new long[0];
private Dictionary<long, long[]> toNodes;
public long[] To(long from) {
long[] res = null;
if (toNodes.TryGetValue(from, out res))
return res;
else
return empty;
}
public IEnumerable<Pair<long, long>> GetRouteEdges(long from, long to) {
return GetRouteEdgesImpl(from, to).Skip(1);
}
private IEnumerable<Pair<long, long>> GetRouteEdgesImpl(long from,
long to) {
var routeNodes = GetRouteNodes(from, to);
var current = -1L;
foreach (var next in routeNodes) {
yield return new Pair<long, long>(current, next);
current = next;
}
}
public IEnumerable<long> GetRouteNodes(long from, long to) {
Stack<long> routeNodes = new Stack<long>();
HashSet<long> checkedNodes = new HashSet<long>();
GetRouteNodes(from, to, routeNodes, checkedNodes);
return routeNodes.Reverse();
}
private bool GetRouteNodes(long current, long dest, Stack<long> routeNodes,
HashSet<long> checkedNodes) {
routeNodes.Push(current);
checkedNodes.Add(current);
if (current == dest)
return true;
foreach (var next in toNodes[current]) {
if (checkedNodes.Contains(next))
continue;
if (GetRouteNodes(next, dest, routeNodes, checkedNodes))
return true;
}
routeNodes.Pop();
return false;
}
}
public class PriorityQueue<TKey, TState>
where TKey : IComparable<TKey> {
public int Count { get; private set; }
private readonly Func<TState, TKey> keySelector;
private readonly bool desc;
private TState[] states = new TState[65536];
private TKey[] keys = new TKey[65536];
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PriorityQueue(Func<TState, TKey> keySelector, bool desc = false) {
this.keySelector = keySelector;
this.desc = desc;
}
public TState Top {
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
get {
ValidateNonEmpty();
return states[1];
}
}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
public TState Dequeue() {
var top = Top;
var item = states[Count];
var key = keys[Count];
Count--;
int index = 1;
while (true) {
if ((index << 1) >= Count) {
if (index << 1 > Count)
break;
if (key.CompareTo(keys[index << 1]) <= 0 ^ desc)
break;
states[index] = states[index << 1];
keys[index] = keys[index << 1];
index <<= 1;
} else {
var nextIndex =
keys[index << 1].CompareTo(keys[(index << 1) + 1]) <= 0 ^ desc
? (index << 1)
: (index << 1) + 1;
if (key.CompareTo(keys[nextIndex]) <= 0 ^ desc)
break;
states[index] = states[nextIndex];
keys[index] = keys[nextIndex];
index = nextIndex;
}
}
states[index] = item;
keys[index] = key;
return top;
}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enqueue(TState state) {
var key = keySelector.Invoke(state);
Count++;
int index = Count;
if (states.Length == Count)
Extend(states.Length * 2);
while ((index >> 1) != 0) {
if (keys[index >> 1].CompareTo(key) <= 0 ^ desc)
break;
states[index] = states[index >> 1];
keys[index] = keys[index >> 1];
index >>= 1;
}
states[index] = state;
keys[index] = key;
}
//[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Extend(int newSize) {
TState[] newStates = new TState[newSize];
TKey[] newKeys = new TKey[newSize];
states.CopyTo(newStates, 0);
keys.CopyTo(newKeys, 0);
states = newStates;
keys = newKeys;
}
private void ValidateNonEmpty() {
if (Count == 0)
throw new IndexOutOfRangeException();
}
}
public class BinaryIndexTree {
long length;
long[] binaryIndexedTree;
public BinaryIndexTree(long length) {
this.length = length;
binaryIndexedTree = new long[length + 1];
}
public void Add(long indexZeroBase, long additional) {
// i += i & -i
// 1が立っている最下位ビットを足す、の意味
for (long i = indexZeroBase + 1; i <= length; i += i & -i) {
binaryIndexedTree[i] += additional;
}
}
public long Sum(long indexZeroBase) {
long result = 0;
// i += i & -i
// 1が立っている最下位ビットを引く、の意味
for (long i = indexZeroBase + 1; i > 0; i -= i & -i) {
result += binaryIndexedTree[i];
}
return result;
}
}
public static class BinarySearch {
public static long GetFirstIndexGreater<T>(T x, IList<T> listOrdered)
where T : IComparable {
return GetFirstIndexGreater(x, listOrdered, 0, listOrdered.Count - 1);
}
public static long GetFirstIndexGreater<T>(T x, IList<T> listOrdered,
int low, int high)
where T : IComparable {
var count = listOrdered.Count;
if (count == 0)
return low;
if (listOrdered[high].CompareTo(x) <= 0)
return high + 1;
while (low < high) {
var mid = (low + high) / 2;
if (listOrdered[mid].CompareTo(x) > 0)
high = mid;
else
low = mid + 1;
}
return low;
}
public static long GetLastIndexLess<T>(T x, IList<T> listOrdered)
where T : IComparable {
return GetLastIndexLess(x, listOrdered, 0, listOrdered.Count - 1);
}
public static long GetLastIndexLess<T>(T x, IList<T> listOrdered, int low,
int high)
where T : IComparable {
var count = listOrdered.Count;
if (count == 0)
return low - 1;
if (listOrdered[0].CompareTo(x) >= 0)
return low - 1;
while (low < high) {
var mid = (low + high + 1) / 2;
if (listOrdered[mid].CompareTo(x) < 0)
low = mid;
else
high = mid - 1;
}
return low;
}
}
public static class BellmanFord {
public class Vertex {
public long Distance { get; set; }
public Vertex() { Distance = long.MaxValue; }
}
public class Edge {
public int From { get; private set; }
public int To { get; private set; }
public long Weight { get; private set; }
public Edge(int from, int to, long weight) {
From = from;
To = to;
Weight = weight;
}
}
private static void GetReachable(int origin, ref HashSet<int> reached,
ref Dictionary<int, int[]> paths) {
if (reached.Contains(origin))
return;
reached.Add(origin);
if (paths.ContainsKey(origin) == false)
return;
foreach (var p in paths[origin])
GetReachable(p, ref reached, ref paths);
}
/// <summary>
/// null: 負の無限大
/// long.MaxValue: たどり着けない
/// その他: 距離
/// </summary>
public static long? RunBellmanFord(int vertexCount, List<Edge> rawEdges,
int source, int dest) {
var forwards =
rawEdges.GroupBy(x => x.From)
.ToDictionary(x => x.Key, x => x.Select(xs => xs.To).ToArray());
var reverses = rawEdges.GroupBy(x => x.To).ToDictionary(
x => x.Key, x => x.Select(xs => xs.From).ToArray());
var fromSource = new HashSet<int>();
var toDest = new HashSet<int>();
GetReachable(source, ref fromSource, ref forwards);
GetReachable(dest, ref toDest, ref reverses);
var edges = rawEdges.Where(e => fromSource.Contains(e.From))
.Where(e => fromSource.Contains(e.To))
.Where(e => toDest.Contains(e.From))
.Where(e => toDest.Contains(e.To))
.ToArray();
// initialize distances
var vertices = new List<Vertex>();
for (int i = 0; i < vertexCount; i++)
vertices.Add(new Vertex());
vertices[source].Distance = 0L;
// update distances
for (int i = 0; i < vertices.Count; i++) {
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance == long.MaxValue)
continue;
var newDistance = from.Distance + e.Weight;
if (to.Distance > newDistance) {
to.Distance = newDistance;
}
}
}
// check negative cycle
foreach (var e in edges) {
var from = vertices[e.From];
var to = vertices[e.To];
if (from.Distance + e.Weight < to.Distance)
return null;
}
return vertices[dest].Distance;
}
}
public static long Gcd(int a, int b) => Gcd((long)a, (long)b);
public static long Gcd(long a, long b) {
if (a < b)
return GcdImpl(b, a);
else
return GcdImpl(a, b);
}
private static long GcdImpl(long a, long b) {
var remainder = a % b;
if (remainder == 0)
return b;
else
return GcdImpl(b, remainder);
}
public static long Lcm(int a, int b) => Lcm((long)a, (long)b);
public static long Lcm(long a, long b) { return a / Gcd(a, b) * b; }
public static long Pow(int n, int p) => Pow((long)n, (long)p);
public static long Pow(long n, long p) {
var res = 1L;
for (long i = 0; i < p; i++)
res *= n;
return res;
}
public static Dictionary<long, long> Factorize(int n) => Factorize((long)n);
public static Dictionary<long, long> Factorize(long n) {
var res = new Dictionary<long, long>();
var r = n;
for (long i = 2; i * i <= r; i++) {
var c = 0L;
while (r % i == 0) {
c++;
r /= i;
}
if (c > 0)
res.Add(i, c);
}
if (r > 1)
res.Add(r, 1);
return res;
}
public static IEnumerable<long> Divisors(int n) => Divisors((long)n);
public static IEnumerable<long> Divisors(long n) {
var cache = new Stack<long>();
for (long i = 1; i * i <= n; i++) {
if (n % i == 0) {
yield return i;
cache.Push(i);
}
}
var r = cache.Peek();
if (r * r == n)
cache.Pop();
while (cache.Count > 0) {
var i = cache.Pop();
yield return n / i;
}
}
public static IEnumerable<int> Loop(int n) {
for (int i = 0; i < n; i++)
yield return i;
}
public static IEnumerable<long> Loop(long n) {
for (long i = 0L; i < n; i++)
yield return i;
}
}
struct Mint {
public static long Divider {
set { divider = value; }
}
private static long divider = 1000000007L;
public static void Set998244353() { divider = 998244353L; }
public static void Set1000000009() { divider = 1000000009L; }
public long Value { get; }
public override string ToString() => this.Value.ToString();
public Mint(long value) { this.Value = value; }
// public static implicit operator Mint(long a) => new Mint(a % divider);
// public static implicit operator Mint(int a) => new Mint(a % divider);
// public static explicit operator long(Mint a) => a.Value;
// public static explicit operator int(Mint a) => (int)a.Value;
public static Mint
operator +(Mint a, Mint b) => new Mint((a.Value + b.Value) % divider);
public static Mint operator +(Mint a, long b) => a + new Mint(b);
public static Mint operator +(Mint a, int b) => a + new Mint(b);
public static Mint operator -(Mint a, Mint b) {
var t = (a.Value - b.Value) % divider;
if (t < 0L)
t += divider;
return new Mint(t);
}
public static Mint operator -(Mint a, long b) => a - new Mint(b);
public static Mint operator -(Mint a, int b) => a - new Mint(b);
public static Mint
operator *(Mint a, Mint b) => new Mint((a.Value * b.Value) % divider);
public static Mint operator *(Mint a, long b) => a * new Mint(b);
public static Mint operator *(Mint a, int b) => a * new Mint(b);
public static Mint operator /(Mint a, Mint b) =>
new Mint((a.Value * InvImpl(b.Value)) % divider);
public static Mint operator /(Mint a, long b) => a / new Mint(b);
public static Mint operator /(Mint a, int b) => a / new Mint(b);
public Mint Pow(long p) => new Mint(PowImpl(Value, p));
public static Mint Pow(long a, long p) => new Mint(PowImpl(a, p));
private static long PowImpl(long a, long p) {
if (p == 0L)
return 1L;
if (p == 1L)
return a;
var halfP = p / 2L;
var halfPowered = PowImpl(a, halfP);
var powered = halfPowered * halfPowered % divider;
return p % 2L == 0L ? powered : powered * a % divider;
}
public static Mint Inv(long a) => new Mint(InvImpl(a));
private static readonly Dictionary<long, long> invCache =
new Dictionary<long, long>();
private static long InvImpl(long a) {
long cache;
if (invCache.TryGetValue(a, out cache))
return cache;
var result = PowImpl(a, divider - 2L);
invCache.Add(a, result);
return result;
}
public static Mint Fac(long a) => new Mint(FacImpl(a));
private static long[] facCache = new long[262144];
private static long cachedFac = 0L;
private static long FacImpl(long a) {
if (a >= divider)
return 0L;
facCache[0] = 1L;
if (facCache.LongLength <= a) {
long newSize = facCache.LongLength;
while (newSize <= a) {
newSize *= 2;
}
ExtendFacCache(newSize);
}
if (cachedFac < a) {
var val = facCache[cachedFac];
var start = cachedFac + 1L;
for (long i = start; i <= a; i++) {
val = (val * i) % divider;
facCache[i] = val;
}
cachedFac = a;
}
return facCache[a];
}
private static void ExtendFacCache(long newSize) {
long[] newFacCache = new long[newSize];
facCache.CopyTo(newFacCache, 0);
facCache = newFacCache;
}
public static Mint Perm(long n, long r) => new Mint(PermImpl(n, r));
private static long PermImpl(long n, long r) {
if (n < r)
return 0L;
if (r <= 0L)
return 1L;
var nn = FacImpl(n);
var nr = FacImpl(n - r);
return (nn * InvImpl(nr)) % divider;
}
public static Mint Comb(long n, long r) => new Mint(CombImpl(n, r));
private static long CombImpl(long n, long r) {
if (n < r)
return 0L;
if (n == r)
return 1L;
if (n - r < r)
return CombImpl(n, n - r);
var nn = FacImpl(n);
var nr = FacImpl(n - r);
var rr = FacImpl(r);
var nrrr = (nr * rr) % divider;
return (nn * InvImpl(nrrr)) % divider;
}
}
}
|
[["+", 0, 200, 0, 212, 0, 16, 31, 16, 17, 72], ["+", 0, 200, 0, 212, 0, 16, 31, 16, 12, 203]]
| 8
| 8,219
| 2
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
ReadData re;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
re = new ReadData();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int Q = re.i();
for (int q = 0; q < Q; q++) {
long A = re.l();
long B = re.l();
long C = re.l();
long D = re.l();
if (B > D || A < B) {
sb.Append("No\n");
continue;
}
long g = gcd(B, D);
long bf = 0;
long bl = 3000000000000000000;
while (bf != bl) {
long bc = (bf + bl + 1) / 2;
if (A - bc * g > C - B) {
bf = bc;
} else {
bl = bc - 1;
}
}
A -= bf * g;
if (A >= 0) {
sb.Append("Yes\n");
} else {
sb.Append("No\n");
}
}
}
long gcd(long a, long b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
}
class ReadData {
string[] str;
int counter;
public ReadData() { counter = 0; }
public string s() {
if (counter == 0) {
str = Console.ReadLine().Split(' ');
counter = str.Length;
}
counter--;
return str[str.Length - counter - 1];
}
public int i() { return int.Parse(s()); }
public long l() { return long.Parse(s()); }
public double d() { return double.Parse(s()); }
public int[] ia(int N) {
int[] ans = new int[N];
for (int j = 0; j < N; j++) {
ans[j] = i();
}
return ans;
}
public int[] ia() {
str = Console.ReadLine().Split(' ');
counter = 0;
int[] ans = new int[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = int.Parse(str[j]);
}
return ans;
}
public long[] la(int N) {
long[] ans = new long[N];
for (int j = 0; j < N; j++) {
ans[j] = l();
}
return ans;
}
public long[] la() {
str = Console.ReadLine().Split(' ');
counter = 0;
long[] ans = new long[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = long.Parse(str[j]);
}
return ans;
}
public double[] da(int N) {
double[] ans = new double[N];
for (int j = 0; j < N; j++) {
ans[j] = d();
}
return ans;
}
public double[] da() {
str = Console.ReadLine().Split(' ');
counter = 0;
double[] ans = new double[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = double.Parse(str[j]);
}
return ans;
}
public List<int>[] g(int N, int[] f, int[] t) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < f.Length; j++) {
ans[f[j]].Add(t[j]);
ans[t[j]].Add(f[j]);
}
return ans;
}
public List<int>[] g(int N, int M) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
public List<int>[] g() {
int N = i();
int M = i();
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
}
public static class Define { public const long mod = 1000000007; }
public static class Debug {
public static void Print(double[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(double[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(double[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(long[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(long[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(long[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(int[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(int[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(int[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
}
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve {
public Solve() {}
StringBuilder sb;
ReadData re;
public static int Main() {
new Solve().Run();
return 0;
}
void Run() {
sb = new StringBuilder();
re = new ReadData();
Calc();
Console.Write(sb.ToString());
}
void Calc() {
int Q = re.i();
for (int q = 0; q < Q; q++) {
long A = re.l();
long B = re.l();
long C = re.l();
long D = re.l();
if (B > D || A < B) {
sb.Append("No\n");
continue;
}
long g = gcd(B, D);
long bf = 0;
long bl = 3000000000000000000;
while (bf != bl) {
long bc = (bf + bl + 1) / 2;
if (3000000000000000000 / g > bc && A - bc * g > C - B) {
bf = bc;
} else {
bl = bc - 1;
}
}
A -= bf * g;
if (A >= 0) {
sb.Append("Yes\n");
} else {
sb.Append("No\n");
}
}
}
long gcd(long a, long b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
}
class ReadData {
string[] str;
int counter;
public ReadData() { counter = 0; }
public string s() {
if (counter == 0) {
str = Console.ReadLine().Split(' ');
counter = str.Length;
}
counter--;
return str[str.Length - counter - 1];
}
public int i() { return int.Parse(s()); }
public long l() { return long.Parse(s()); }
public double d() { return double.Parse(s()); }
public int[] ia(int N) {
int[] ans = new int[N];
for (int j = 0; j < N; j++) {
ans[j] = i();
}
return ans;
}
public int[] ia() {
str = Console.ReadLine().Split(' ');
counter = 0;
int[] ans = new int[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = int.Parse(str[j]);
}
return ans;
}
public long[] la(int N) {
long[] ans = new long[N];
for (int j = 0; j < N; j++) {
ans[j] = l();
}
return ans;
}
public long[] la() {
str = Console.ReadLine().Split(' ');
counter = 0;
long[] ans = new long[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = long.Parse(str[j]);
}
return ans;
}
public double[] da(int N) {
double[] ans = new double[N];
for (int j = 0; j < N; j++) {
ans[j] = d();
}
return ans;
}
public double[] da() {
str = Console.ReadLine().Split(' ');
counter = 0;
double[] ans = new double[str.Length];
for (int j = 0; j < str.Length; j++) {
ans[j] = double.Parse(str[j]);
}
return ans;
}
public List<int>[] g(int N, int[] f, int[] t) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < f.Length; j++) {
ans[f[j]].Add(t[j]);
ans[t[j]].Add(f[j]);
}
return ans;
}
public List<int>[] g(int N, int M) {
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
public List<int>[] g() {
int N = i();
int M = i();
List<int>[] ans = new List<int>[N];
for (int j = 0; j < N; j++) {
ans[j] = new List<int>();
}
for (int j = 0; j < M; j++) {
int f = i() - 1;
int t = i() - 1;
ans[f].Add(t);
ans[t].Add(f);
}
return ans;
}
}
public static class Define { public const long mod = 1000000007; }
public static class Debug {
public static void Print(double[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(double[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(double[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(long[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(long[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(long[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
public static void Print(int[,,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
for (int l = 0; l < k.GetLength(2); l++) {
Console.Write(k[i, j, l] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
public static void Print(int[,] k) {
for (int i = 0; i < k.GetLength(0); i++) {
for (int j = 0; j < k.GetLength(1); j++) {
Console.Write(k[i, j] + " ");
}
Console.WriteLine();
}
}
public static void Print(int[] k) {
for (int i = 0; i < k.Length; i++) {
Console.WriteLine(k[i]);
}
}
}
|
[["+", 0, 57, 15, 16, 31, 16, 31, 16, 31, 203], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 16, 31, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 47], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 12, 22], ["+", 0, 52, 8, 196, 0, 57, 15, 16, 17, 98]]
| 8
| 1,887
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
static void Main(string[] args) {
var S = sc.ReadStr();
if (S[0] != 'A') {
Console.WriteLine("WA");
} else {
var count = 0;
foreach (var c in S.Take(S.Length - 1).Skip(2)) {
if (c == 'C')
count++;
}
if (count != 1) {
Console.WriteLine("WA");
return;
}
var lcount = 0;
foreach (var c in S) {
var n = (int)c;
if (((int)'A' <= n && n <= (int)'Z')) {
lcount++;
}
}
if (lcount > 2) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
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 S = sc.ReadStr();
if (S[0] != 'A') {
Console.WriteLine("WA");
return;
} else {
var count = 0;
foreach (var c in S.Take(S.Length - 1).Skip(2)) {
if (c == 'C')
count++;
}
if (count != 1) {
Console.WriteLine("WA");
return;
}
var lcount = 0;
foreach (var c in S) {
var n = (int)c;
if (((int)'A' <= n && n <= (int)'Z')) {
lcount++;
}
}
if (lcount > 2) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
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, 64, 196, 0, 37, 0, 38], ["+", 8, 196, 0, 57, 64, 196, 0, 37, 0, 35]]
| 8
| 1,170
| 2
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using static System.Math;
using System.Text;
namespace Program {
public static class ABC104B {
static public void Solve() {
var S = NS;
var c = false;
if (S[0] == 'A') {
for (var i = 1; i < S.Length; i++) {
if (i >= 2 && i <= S.Length - 2) {
if (S[i] == 'C') {
if (c) {
Console.WriteLine("WA");
return;
}
c = true;
continue;
}
}
if (S[i] - 'a' < 0 || S[i] - 'a' > 26) {
Console.WriteLine("WA");
return;
}
}
}
Console.WriteLine("AC");
}
static public void Main(string[] args) {
if (args.Length == 0) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
Solve();
Console.Out.Flush();
}
static Random rand = new Random();
static class Console_ {
private static Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
}
static long NN => long.Parse(Console_.NextString());
static double ND => double.Parse(Console_.NextString());
static string NS => Console_.NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => rand.Next());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void RevSort<T>(T[] l)
where T : IComparable { Array.Sort(l, (x, y) => y.CompareTo(x)); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void RevSort<T>(T[] l, Comparison<T> comp)
where T : IComparable { Array.Sort(l, (x, y) => comp(y, x)); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<long> Primes(long x) {
if (x < 2)
yield break;
yield return 2;
var halfx = x / 2;
var table = new bool[halfx + 1];
var max = (long)(Math.Sqrt(x) / 2);
for (long i = 1; i <= max; ++i) {
if (table[i])
continue;
var add = 2 * i + 1;
yield return add;
for (long j = 2 * i * (i + 1); j <= halfx; j += add)
table[j] = true;
}
for (long i = max + 1; i <= halfx; ++i)
if (!table[i] && 2 * i + 1 <= x)
yield return 2 * i + 1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<long> Factors(long x) {
if (x < 2)
yield break;
while (x % 2 == 0) {
x /= 2;
yield return 2;
}
var max = (long)Math.Sqrt(x);
for (long i = 3; i <= max; i += 2)
while (x % i == 0) {
x /= i;
yield return i;
}
if (x != 1)
yield return x;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<long> Divisor(long x) {
if (x < 1)
yield break;
var max = (long)Math.Sqrt(x);
for (long i = 1; i <= max; ++i) {
if (x % i != 0)
continue;
yield return i;
if (i != x / i)
yield return x / i;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long GCD(long a, long b) {
while (b > 0) {
var tmp = b;
b = a % b;
a = tmp;
}
return a;
}
static long LCM(long a, long b) => a * b / GCD(a, b);
class PQ<T>
where T : IComparable {
private List<T> h;
private Comparison<T> c;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, Comparison<T> c, bool asc = true) {
h = new List<T>(cap);
this.c = asc ? c : (x, y) => c(y, x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(Comparison<T> c, bool asc = true) {
h = new List<T>();
this.c = asc ? c : (x, y) => c(y, x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, bool asc = true)
: this(cap, (x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Push(T v) {
var i = h.Count;
h.Add(v);
while (i > 0) {
var ni = (i - 1) / 2;
if (c(v, h[ni]) >= 0)
break;
h[i] = h[ni];
i = ni;
}
h[i] = v;
}
public T Peek => h[0];
public int Count => h.Count;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Pop() {
var r = h[0];
var v = h[h.Count - 1];
h.RemoveAt(h.Count - 1);
if (h.Count == 0)
return r;
var i = 0;
while (i * 2 + 1 < h.Count) {
var i1 = i * 2 + 1;
var i2 = i * 2 + 2;
if (i2 < h.Count && c(h[i1], h[i2]) > 0)
i1 = i2;
if (c(v, h[i1]) <= 0)
break;
h[i] = h[i1];
i = i1;
}
h[i] = v;
return r;
}
}
class PQ<TKey, TValue>
where TKey : IComparable {
private PQ<Tuple<TKey, TValue>> q;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, Comparison<TKey> c, bool asc = true) {
q = new PQ<Tuple<TKey, TValue>>(cap, (x, y) => c(x.Item1, y.Item1), asc);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(Comparison<TKey> c, bool asc = true) {
q = new PQ<Tuple<TKey, TValue>>((x, y) => c(x.Item1, y.Item1), asc);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, bool asc = true)
: this(cap, (x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Push(TKey k, TValue v) => q.Push(Tuple.Create(k, v));
public Tuple<TKey, TValue> Peek => q.Peek;
public int Count => q.Count;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Tuple<TKey, TValue> Pop() => q.Pop();
}
struct Mod : IEquatable<object> {
static public long _mod = 1000000007;
private long _val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Mod(long x) {
if (x < _mod && x >= 0)
_val = x;
else if ((_val = x % _mod) < 0)
_val += _mod;
}
static public implicit operator Mod(long x) => new Mod(x);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public implicit operator long(Mod x) => x._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator +(Mod x, Mod y) => x._val + y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator -(Mod x, Mod y) => x._val - y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator *(Mod x, Mod y) => x._val * y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator /(Mod x, Mod y) => x._val * Inverse(y._val);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public bool operator ==(Mod x, Mod y) => x._val == y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public bool operator !=(Mod x, Mod y) => x._val != y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public long Inverse(long x) {
long b = _mod, r = 1, u = 0, t = 0;
while (b > 0) {
var q = x / b;
t = u;
u = r - q * u;
r = t;
t = b;
b = x - q * b;
x = t;
}
return r < 0 ? r + _mod : r;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
bool IEquatable<object>.Equals(object obj) => obj == null
? false
: Equals((Mod)obj);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj) => obj == null ? false
: Equals((Mod)obj);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Mod obj) => obj == null ? false : _val == obj._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode() => _val.GetHashCode();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString() => _val.ToString();
static private List<Mod> _fact = new List<Mod>() { 1 };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static private void Build(long n) {
if (n >= _fact.Count)
for (int i = _fact.Count; i <= n; ++i)
_fact.Add(_fact[i - 1] * i);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod Comb(long n, long k) {
Build(n);
if (n == 0 && k == 0)
return 1;
if (n < k || n < 0)
return 0;
return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
}
}
struct Mat<T> {
private T[,] m;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Mat(T[,] v) { m = (T[,])v.Clone(); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public implicit operator Mat<T>(T[,] v) => new Mat<T>(v);
public T this[int r, int c] {
get { return m[r, c]; }
set { m[r, c] = value; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator +(Mat<T> a, T x) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] += (dynamic)x;
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator +(Mat<T> a, Mat<T> b) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] += (dynamic)b[r, c];
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator -(Mat<T> a, T x) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] -= (dynamic)x;
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator -(Mat<T> a, Mat<T> b) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] -= (dynamic)b[r, c];
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator *(Mat<T> a, T x) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] *= (dynamic)x;
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator *(Mat<T> a, Mat<T> b) {
var nr = a.m.GetLength(0);
var nc = b.m.GetLength(1);
var tm = new T[nr, nc];
for (int i = 0; i < nr; ++i)
for (int j = 0; j < nc; ++j)
tm[i, j] = (dynamic)0;
for (int r = 0; r < nr; ++r)
for (int c = 0; c < nc; ++c)
for (int i = 0; i < a.m.GetLength(1); ++i)
tm[r, c] += a[r, i] * (dynamic)b[i, c];
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> Pow(Mat<T> x, long y) {
var n = x.m.GetLength(0);
var t = (Mat<T>)new T[n, n];
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
t[i, j] = (dynamic)(i == j ? 1 : 0);
while (y != 0) {
if ((y & 1) == 1)
t *= x;
x *= x;
y >>= 1;
}
return t;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static Mat<T> Pow<T>(Mat<T> x, long y) => Mat<T>.Pow(x, y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static T Pow<T>(T x, long y) {
T a = (dynamic)1;
while (y != 0) {
if ((y & 1) == 1)
a *= (dynamic)x;
x *= (dynamic)x;
y >>= 1;
}
return a;
}
static List<long> _fact = new List<long>() { 1 };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void _Build(long n) {
if (n >= _fact.Count)
for (int i = _fact.Count; i <= n; ++i)
_fact.Add(_fact[i - 1] * i);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long Comb(long n, long k) {
_Build(n);
if (n == 0 && k == 0)
return 1;
if (n < k || n < 0)
return 0;
return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
}
}
}
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using static System.Math;
using System.Text;
namespace Program {
public static class ABC104B {
static public void Solve() {
var S = NS;
var c = false;
if (S[0] == 'A') {
for (var i = 1; i < S.Length; i++) {
if (i >= 2 && i <= S.Length - 2) {
if (S[i] == 'C') {
if (c) {
Console.WriteLine("WA");
return;
}
c = true;
continue;
}
}
if (S[i] - 'a' < 0 || S[i] - 'a' > 26) {
Console.WriteLine("WA");
return;
}
}
}
Console.WriteLine(c ? "AC" : "WA");
}
static public void Main(string[] args) {
if (args.Length == 0) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
Solve();
Console.Out.Flush();
}
static Random rand = new Random();
static class Console_ {
private static Queue<string> param = new Queue<string>();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string NextString() {
if (param.Count == 0)
foreach (var item in Console.ReadLine().Split(' '))
param.Enqueue(item);
return param.Dequeue();
}
}
static long NN => long.Parse(Console_.NextString());
static double ND => double.Parse(Console_.NextString());
static string NS => Console_.NextString();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<T>
OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => rand.Next());
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v,
(int)n);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s,
(int)c);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void RevSort<T>(T[] l)
where T : IComparable { Array.Sort(l, (x, y) => y.CompareTo(x)); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void RevSort<T>(T[] l, Comparison<T> comp)
where T : IComparable { Array.Sort(l, (x, y) => comp(y, x)); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<long> Primes(long x) {
if (x < 2)
yield break;
yield return 2;
var halfx = x / 2;
var table = new bool[halfx + 1];
var max = (long)(Math.Sqrt(x) / 2);
for (long i = 1; i <= max; ++i) {
if (table[i])
continue;
var add = 2 * i + 1;
yield return add;
for (long j = 2 * i * (i + 1); j <= halfx; j += add)
table[j] = true;
}
for (long i = max + 1; i <= halfx; ++i)
if (!table[i] && 2 * i + 1 <= x)
yield return 2 * i + 1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<long> Factors(long x) {
if (x < 2)
yield break;
while (x % 2 == 0) {
x /= 2;
yield return 2;
}
var max = (long)Math.Sqrt(x);
for (long i = 3; i <= max; i += 2)
while (x % i == 0) {
x /= i;
yield return i;
}
if (x != 1)
yield return x;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static IEnumerable<long> Divisor(long x) {
if (x < 1)
yield break;
var max = (long)Math.Sqrt(x);
for (long i = 1; i <= max; ++i) {
if (x % i != 0)
continue;
yield return i;
if (i != x / i)
yield return x / i;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long GCD(long a, long b) {
while (b > 0) {
var tmp = b;
b = a % b;
a = tmp;
}
return a;
}
static long LCM(long a, long b) => a * b / GCD(a, b);
class PQ<T>
where T : IComparable {
private List<T> h;
private Comparison<T> c;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, Comparison<T> c, bool asc = true) {
h = new List<T>(cap);
this.c = asc ? c : (x, y) => c(y, x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(Comparison<T> c, bool asc = true) {
h = new List<T>();
this.c = asc ? c : (x, y) => c(y, x);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, bool asc = true)
: this(cap, (x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Push(T v) {
var i = h.Count;
h.Add(v);
while (i > 0) {
var ni = (i - 1) / 2;
if (c(v, h[ni]) >= 0)
break;
h[i] = h[ni];
i = ni;
}
h[i] = v;
}
public T Peek => h[0];
public int Count => h.Count;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T Pop() {
var r = h[0];
var v = h[h.Count - 1];
h.RemoveAt(h.Count - 1);
if (h.Count == 0)
return r;
var i = 0;
while (i * 2 + 1 < h.Count) {
var i1 = i * 2 + 1;
var i2 = i * 2 + 2;
if (i2 < h.Count && c(h[i1], h[i2]) > 0)
i1 = i2;
if (c(v, h[i1]) <= 0)
break;
h[i] = h[i1];
i = i1;
}
h[i] = v;
return r;
}
}
class PQ<TKey, TValue>
where TKey : IComparable {
private PQ<Tuple<TKey, TValue>> q;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, Comparison<TKey> c, bool asc = true) {
q = new PQ<Tuple<TKey, TValue>>(cap, (x, y) => c(x.Item1, y.Item1), asc);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(Comparison<TKey> c, bool asc = true) {
q = new PQ<Tuple<TKey, TValue>>((x, y) => c(x.Item1, y.Item1), asc);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(int cap, bool asc = true)
: this(cap, (x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public PQ(bool asc = true) : this((x, y) => x.CompareTo(y), asc) {}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Push(TKey k, TValue v) => q.Push(Tuple.Create(k, v));
public Tuple<TKey, TValue> Peek => q.Peek;
public int Count => q.Count;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Tuple<TKey, TValue> Pop() => q.Pop();
}
struct Mod : IEquatable<object> {
static public long _mod = 1000000007;
private long _val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Mod(long x) {
if (x < _mod && x >= 0)
_val = x;
else if ((_val = x % _mod) < 0)
_val += _mod;
}
static public implicit operator Mod(long x) => new Mod(x);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public implicit operator long(Mod x) => x._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator +(Mod x, Mod y) => x._val + y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator -(Mod x, Mod y) => x._val - y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator *(Mod x, Mod y) => x._val * y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod operator /(Mod x, Mod y) => x._val * Inverse(y._val);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public bool operator ==(Mod x, Mod y) => x._val == y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public bool operator !=(Mod x, Mod y) => x._val != y._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public long Inverse(long x) {
long b = _mod, r = 1, u = 0, t = 0;
while (b > 0) {
var q = x / b;
t = u;
u = r - q * u;
r = t;
t = b;
b = x - q * b;
x = t;
}
return r < 0 ? r + _mod : r;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
bool IEquatable<object>.Equals(object obj) => obj == null
? false
: Equals((Mod)obj);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj) => obj == null ? false
: Equals((Mod)obj);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Equals(Mod obj) => obj == null ? false : _val == obj._val;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override int GetHashCode() => _val.GetHashCode();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override string ToString() => _val.ToString();
static private List<Mod> _fact = new List<Mod>() { 1 };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static private void Build(long n) {
if (n >= _fact.Count)
for (int i = _fact.Count; i <= n; ++i)
_fact.Add(_fact[i - 1] * i);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mod Comb(long n, long k) {
Build(n);
if (n == 0 && k == 0)
return 1;
if (n < k || n < 0)
return 0;
return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
}
}
struct Mat<T> {
private T[,] m;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Mat(T[,] v) { m = (T[,])v.Clone(); }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public implicit operator Mat<T>(T[,] v) => new Mat<T>(v);
public T this[int r, int c] {
get { return m[r, c]; }
set { m[r, c] = value; }
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator +(Mat<T> a, T x) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] += (dynamic)x;
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator +(Mat<T> a, Mat<T> b) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] += (dynamic)b[r, c];
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator -(Mat<T> a, T x) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] -= (dynamic)x;
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator -(Mat<T> a, Mat<T> b) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] -= (dynamic)b[r, c];
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator *(Mat<T> a, T x) {
var tm = (T[,])a.m.Clone();
for (int r = 0; r < tm.GetLength(0); ++r)
for (int c = 0; c < tm.GetLength(1); ++c)
tm[r, c] *= (dynamic)x;
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> operator *(Mat<T> a, Mat<T> b) {
var nr = a.m.GetLength(0);
var nc = b.m.GetLength(1);
var tm = new T[nr, nc];
for (int i = 0; i < nr; ++i)
for (int j = 0; j < nc; ++j)
tm[i, j] = (dynamic)0;
for (int r = 0; r < nr; ++r)
for (int c = 0; c < nc; ++c)
for (int i = 0; i < a.m.GetLength(1); ++i)
tm[r, c] += a[r, i] * (dynamic)b[i, c];
return tm;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public Mat<T> Pow(Mat<T> x, long y) {
var n = x.m.GetLength(0);
var t = (Mat<T>)new T[n, n];
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
t[i, j] = (dynamic)(i == j ? 1 : 0);
while (y != 0) {
if ((y & 1) == 1)
t *= x;
x *= x;
y >>= 1;
}
return t;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static Mat<T> Pow<T>(Mat<T> x, long y) => Mat<T>.Pow(x, y);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static T Pow<T>(T x, long y) {
T a = (dynamic)1;
while (y != 0) {
if ((y & 1) == 1)
a *= (dynamic)x;
x *= (dynamic)x;
y >>= 1;
}
return a;
}
static List<long> _fact = new List<long>() { 1 };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static void _Build(long n) {
if (n >= _fact.Count)
for (int i = _fact.Count; i <= n; ++i)
_fact.Add(_fact[i - 1] * i);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static long Comb(long n, long k) {
_Build(n);
if (n == 0 && k == 0)
return 1;
if (n < k || n < 0)
return 0;
return _fact[(int)n] / _fact[(int)(n - k)] / _fact[(int)k];
}
}
}
|
[["+", 0, 213, 3, 4, 0, 28, 0, 41, 15, 22], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 101], ["+", 3, 4, 0, 28, 0, 41, 64, 5, 0, 62], ["+", 0, 213, 3, 4, 0, 28, 0, 41, 0, 102], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 62], ["+", 3, 4, 0, 28, 0, 41, 75, 5, 0, 222]]
| 8
| 3,785
| 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) { new Program().Solve(); }
public void Solve() {
string s = Console.ReadLine();
bool Flag = true;
bool Cflag = false;
for (int i = 0; i < s.Length; i++) {
if (i == 0) {
if (s[0] != 'A')
Flag = true;
} else if (2 <= i && i < s.Length - 1) {
if (('a' <= s[i] && s[i] <= 'z')) {
continue;
} else if (s[i] == 'C' && Cflag == false) {
Cflag = true;
continue;
}
Flag = false;
} else {
if (('a' <= s[i] && s[i] <= 'z'))
continue;
Flag = false;
}
}
if (Flag)
Console.WriteLine("AC");
else
Console.WriteLine("WA");
}
}
}
|
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) { new Program().Solve(); }
public void Solve() {
string s = Console.ReadLine();
bool Flag = true;
bool Cflag = false;
for (int i = 0; i < s.Length; i++) {
if (i == 0) {
if (s[0] != 'A')
Flag = false;
} else if (2 <= i && i < s.Length - 1) {
if (('a' <= s[i] && s[i] <= 'z')) {
continue;
} else if (s[i] == 'C' && Cflag == false) {
Cflag = true;
continue;
}
Flag = false;
} else {
if (('a' <= s[i] && s[i] <= 'z'))
continue;
Flag = false;
}
}
if (Flag && Cflag)
Console.WriteLine("AC");
else
Console.WriteLine("WA");
}
}
}
|
[["-", 0, 57, 64, 1, 0, 11, 12, 211, 0, 146], ["+", 0, 57, 64, 1, 0, 11, 12, 211, 0, 147], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 247
| 4
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
if (s[0] != 'A') {
Console.WriteLine("WA");
return;
}
int Cpos = -1;
int CCount = 0;
for (int i = 2; i < s.Length - 2; i++) {
if (s[i] == 'C') {
Cpos = i;
CCount++;
}
}
if (Cpos == -1 || CCount != 1) {
Console.WriteLine("WA");
return;
}
for (int i = 1; i < s.Length; i++) {
if (i != Cpos && s[i] - 'A' <= 26) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
|
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main(string[] args) {
string s = Console.ReadLine();
if (s[0] != 'A') {
Console.WriteLine("WA");
return;
}
int Cpos = -1;
int CCount = 0;
for (int i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C') {
Cpos = i;
CCount++;
}
}
if (Cpos == -1 || CCount != 1) {
Console.WriteLine("WA");
return;
}
for (int i = 1; i < s.Length; i++) {
if (i != Cpos && s[i] - 'A' <= 26) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 195
| 2
|
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;
void calc() {
cin = new Scanner();
string S = cin.next();
string ans = "No";
int Ccount = 0;
for (int i = 2; i < S.Length - 1; i++) {
if (S[i] - 'C' == 0)
Ccount++;
}
for (int i = 0; i < S.Length; i++) {
if (S[i] - 'A' != 0 && S[i] - 'C' != 0 && char.IsUpper(S[i]))
Ccount += 2;
}
if (S[0] - 'C' == 0 || S[1] - 'C' == 0 || S[S.Length - 1] - 'C' == 0)
Ccount += 2;
if (S[0] - 'A' == 0 && Ccount == 1)
ans = "Yes";
Console.WriteLine(ans);
}
}
class Scanner {
string[] s;
int i;
char[] cs = new char[] { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length)
return s[i++];
string st = Console.ReadLine();
while (st == "")
st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
if (s.Length == 0)
return next();
i = 0;
return s[i++];
}
public int nextInt() { return int.Parse(next()); }
public int[] ArrayInt(int N, int add = 0) {
int[] Array = new int[N];
for (int i = 0; i < N; i++) {
Array[i] = nextInt() + add;
}
return Array;
}
public long nextLong() { return long.Parse(next()); }
public long[] ArrayLong(int N, long add = 0) {
long[] Array = new long[N];
for (int i = 0; i < N; i++) {
Array[i] = nextLong() + add;
}
return Array;
}
public double nextDouble() { return double.Parse(next()); }
public double[] ArrayDouble(int N, double add = 0) {
double[] Array = new double[N];
for (int i = 0; i < N; i++) {
Array[i] = nextDouble() + add;
}
return Array;
}
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;
void calc() {
cin = new Scanner();
string S = cin.next();
string ans = "WA";
int Ccount = 0;
for (int i = 2; i < S.Length - 1; i++) {
if (S[i] - 'C' == 0)
Ccount++;
}
for (int i = 0; i < S.Length; i++) {
if (S[i] - 'A' != 0 && S[i] - 'C' != 0 && char.IsUpper(S[i]))
Ccount += 2;
}
if (S[0] - 'C' == 0 || S[1] - 'C' == 0 || S[S.Length - 1] - 'C' == 0)
Ccount += 2;
if (S[0] - 'A' == 0 && Ccount == 1)
ans = "AC";
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;
}
public long GCDLong(long a, long b) {
while (a != 0) {
long t = a;
a = b % a;
b = t;
}
return b;
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["-", 0, 57, 64, 1, 0, 11, 12, 5, 0, 222], ["+", 0, 57, 64, 1, 0, 11, 12, 5, 0, 222]]
| 8
| 657
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
const int MOD = 1000000007;
const int INF = 1 << 30;
static void Main(string[] args) { Solve(); }
static long GCD(long x, long y) {
if (y == 0)
return x;
return GCD(y, x % y);
}
static long LCM(long x, long y) { return x * y / GCD(x, y); }
static void Solve() {
Scan sc = new Scan();
write wr = new write();
bool ac = true;
string S = sc.str;
if (S[0] != 'A')
ac = false;
bool isC = false;
int Ci = -1;
for (int i = 2; i < S.Length - 1; ++i) {
if (!isC && S[i] == 'C') {
isC = true;
Ci = i;
} else if (isC && S[i] == 'C') {
ac = false;
}
}
if (!isC)
ac = false;
for (int i = 0; i < S.Length; ++i) {
if (i != 0 && i != Ci) {
if (S[i] > 'z') {
ac = false;
}
}
}
if (ac)
wr.wri("AC");
else
wr.wri("WA");
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => str.ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
const int MOD = 1000000007;
const int INF = 1 << 30;
static void Main(string[] args) { Solve(); }
static long GCD(long x, long y) {
if (y == 0)
return x;
return GCD(y, x % y);
}
static long LCM(long x, long y) { return x * y / GCD(x, y); }
static void Solve() {
Scan sc = new Scan();
write wr = new write();
bool ac = true;
string S = sc.str;
if (S[0] != 'A')
ac = false;
bool isC = false;
int Ci = -1;
for (int i = 2; i < S.Length - 1; ++i) {
if (!isC && S[i] == 'C') {
isC = true;
Ci = i;
} else if (isC && S[i] == 'C') {
ac = false;
}
}
if (!isC)
ac = false;
for (int i = 0; i < S.Length; ++i) {
if (i != 0 && i != Ci) {
if (S[i] < 'a') {
ac = false;
}
}
}
if (ac)
wr.wri("AC");
else
wr.wri("WA");
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => str.ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
|
[["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 18], ["-", 64, 196, 0, 57, 15, 16, 12, 252, 0, 253], ["+", 64, 196, 0, 57, 15, 16, 12, 252, 0, 253]]
| 8
| 421
| 4
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) { MainStream(); }
static void MainStream() {
char[] s = Console.ReadLine().ToCharArray();
if (Judge(s)) {
Console.WriteLine("AC");
} else {
Console.WriteLine("WA");
}
}
static bool Judge(char[] s) {
int C_count = 0;
int C_index = 0;
if (s[0] != 'A') {
return false;
}
for (int i = 2; i < s.Length - 2; i++) {
if (s[i] == 'C') {
C_count += 1;
C_index = i;
if (C_count > 1) // Cが二個以上
{
return false;
}
}
}
if (C_count != 1) {
return false;
}
for (int i = 1; i < s.Length; i++) {
if (i != C_index) {
if (Char.IsUpper(s[i])) {
return false;
}
}
}
return true;
}
}
}
|
using System;
namespace AtCoder {
class Program {
static void Main(string[] args) { MainStream(); }
static void MainStream() {
char[] s = Console.ReadLine().ToCharArray();
if (Judge(s)) {
Console.WriteLine("AC");
} else {
Console.WriteLine("WA");
}
}
static bool Judge(char[] s) {
int C_count = 0;
int C_index = 0;
if (s[0] != 'A') {
return false;
}
for (int i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C') {
C_count += 1;
C_index = i;
if (C_count > 1) // Cが二個以上
{
return false;
}
}
}
if (C_count != 1) {
return false;
}
for (int i = 1; i < s.Length; i++) {
if (i != C_index) {
if (Char.IsUpper(s[i])) {
return false;
}
}
}
return true;
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 225
| 2
|
using System;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
char[] cha = new char[str.Length];
for (int i = 0; i < str.Length; i++) {
cha[i] = str[i];
}
int cCount = 0;
int cNumber = 0;
for (int i = 2; i < cha.Length - 2; i++) {
if (cha[i].ToString() == "C") {
cCount++;
cNumber = i;
}
}
bool isLow = true;
for (int i = 1; i < cha.Length; i++) {
if (i == cNumber) {
continue;
}
if (cha[i].ToString().CompareTo(cha[i].ToString().ToLower()) != 0) {
isLow = false;
}
}
if (cCount == 1 && isLow && cha[0].ToString() == "A") {
Console.WriteLine("AC");
} else {
Console.WriteLine("WA");
}
}
}
|
using System;
class Program {
static void Main(string[] args) {
string str = Console.ReadLine();
char[] cha = new char[str.Length];
for (int i = 0; i < str.Length; i++) {
cha[i] = str[i];
}
int cCount = 0;
int cNumber = 0;
for (int i = 2; i < cha.Length - 1; i++) {
if (cha[i].ToString() == "C") {
cCount++;
cNumber = i;
}
}
bool isLow = true;
for (int i = 1; i < cha.Length; i++) {
if (i == cNumber) {
continue;
}
if (cha[i].ToString().CompareTo(cha[i].ToString().ToLower()) != 0) {
isLow = false;
}
}
if (cCount == 1 && isLow && cha[0].ToString() == "A") {
Console.WriteLine("AC");
} else {
Console.WriteLine("WA");
}
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 234
| 2
|
using System;
class Program {
static void Main(string[] args) {
var s = Console.ReadLine().ToCharArray();
var f1 = s[0] == 'A';
s[0] = 'a';
var f2 = 0;
var i = 2;
for (; i <= s.Length - 2; i++) {
if (s[i] == 'C') {
s[i] = 'c';
f2++;
}
}
var f3 = true;
for (int j = 0; j < s.Length; j++) {
f3 &= char.IsUpper(s[j]);
}
Console.WriteLine(f1 && f2 == 1 && f3 ? "AC" : "WA");
}
}
|
using System;
class Program {
static void Main(string[] args) {
var s = Console.ReadLine().ToCharArray();
var f1 = s[0] == 'A';
s[0] = 'a';
var f2 = 0;
var i = 2;
for (; i <= s.Length - 2; i++) {
if (s[i] == 'C') {
s[i] = 'c';
f2++;
}
}
var f3 = true;
for (int j = 0; j < s.Length; j++) {
f3 &= char.IsLower(s[j]);
}
Console.WriteLine(f1 && f2 == 1 && f3 ? "AC" : "WA");
}
}
|
[["-", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22], ["+", 0, 1, 0, 11, 12, 213, 63, 214, 141, 22]]
| 8
| 159
| 2
|
using System;
using System.Linq;
namespace B.AcCepted {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
bool flg1, flg2, flg3;
flg1 = str[0] == 'A';
flg2 = str.Substring(2, str.Length - 2).Contains('C');
flg3 = str.Count(x => char.IsUpper(x)) == 2;
if (flg1 && flg2 && flg3)
Console.WriteLine("AC");
else
Console.WriteLine("WA");
}
}
}
|
using System;
using System.Linq;
namespace B.AcCepted {
class Program {
static void Main(string[] args) {
var str = Console.ReadLine();
bool flg1, flg2, flg3;
flg1 = str[0] == 'A';
flg2 = str.Skip(2).Take(str.Length - 3).Contains('C');
flg3 = str.Count(x => char.IsUpper(x)) == 2;
if (flg1 && flg2 && flg3)
Console.WriteLine("AC");
else
Console.WriteLine("WA");
}
}
}
|
[["-", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 205, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["-", 12, 213, 63, 214, 205, 213, 3, 4, 0, 21], ["+", 205, 213, 63, 214, 205, 213, 3, 4, 0, 25], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 0, 131], ["+", 12, 213, 63, 214, 205, 213, 63, 214, 141, 22], ["+", 12, 213, 63, 214, 205, 213, 3, 4, 0, 24], ["-", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 123
| 9
|
using System;
using System.Web;
using System.IO;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static System.Math;
class P {
static void Main() {
Console.WriteLine(
Regex.IsMatch(Console.ReadLine(), "^A[ABD-Za-z]+C[ABD-Za-z]+$") ? "AC"
: "WA");
}
}
|
using System;
using System.Web;
using System.IO;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static System.Math;
class P {
static void Main() {
Console.WriteLine(
Regex.IsMatch(Console.ReadLine(), "^A[a-z]+C[a-z]+$") ? "AC" : "WA");
}
}
|
[["-", 15, 213, 3, 4, 0, 28, 0, 5, 0, 222], ["+", 15, 213, 3, 4, 0, 28, 0, 5, 0, 222]]
| 8
| 120
| 2
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
class A {
static void Main() {
var s = Console.ReadLine();
var a = s.StartsWith("A");
var b = s.Substring(2, s.Length - 3).Count(x => x == 'C') == 1;
var c = !Regex.IsMatch(string.Join("", s.Substring(2).Split('C')), "[A-Z]");
Console.WriteLine(a && b && c ? "AC" : "WA");
}
}
|
using System;
using System.Linq;
using System.Text.RegularExpressions;
class A {
static void Main() {
var s = Console.ReadLine();
var a = s.StartsWith("A");
var b = s.Substring(2, s.Length - 3).Count(x => x == 'C') == 1;
var c = !Regex.IsMatch(string.Join("", s.Substring(1).Split('C')), "[A-Z]");
Console.WriteLine(a && b && c ? "AC" : "WA");
}
}
|
[["-", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203], ["+", 63, 214, 205, 213, 3, 4, 0, 28, 0, 203]]
| 8
| 130
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography.X509Certificates;
using System.Security.Permissions;
using System.Text;
using static System.Console;
using static System.Math;
using static Ex;
class AC {
/*------------------------------------------------------------------*/
private string S;
void Solve() {
io.i(out S);
io.yn(S[0] == 'A' &&
S.Substring(2, S.Length - 4).Count(c => c == 'C') == 1 &&
S.Count(c => 'a' <= c && c <= 'z') == S.Length - 2,
"AC", "WA");
}
/*------------------------------------------------------------------*/
void Test() {
//--- TEST ---//
}
public static void Main(string[] args) => new AC().Stream();
IO io = new IO();
private void Stream() {
/*
var exStdIn = new System.IO.StreamReader("stdin.txt");
SetIn(exStdIn);
Test();
*/
Solve();
io.Flush();
}
}
class IO {
#region INPUT
#region FastRead
private const int Size = 1 << 12;
private readonly Stream _stream = OpenStandardInput();
private readonly byte[] _buffer = new byte[Size];
private int _ptr = 0, _buffLen = 0;
private bool HasNextByte() {
if (_ptr < _buffLen)
return true;
_ptr = 0;
_buffLen = _stream.Read(_buffer, 0, Size);
return _buffLen > 0;
}
private byte ReadByte() {
if (HasNextByte())
return _buffer[_ptr++];
else
// inputの末尾の改行がないとerror
throw new EndOfStreamException();
}
private bool IsAscii(int c) => '!' <= c && c <= '~';
private char NextChar() {
var b = ReadByte();
while (!IsAscii(b))
b = ReadByte();
return (char)b;
}
private string Next() {
var sb = new StringBuilder();
for (var b = NextChar(); IsAscii(b); b = (char)ReadByte())
sb.Append(b);
return sb.ToString();
}
public string String => Next();
public char Char => NextChar();
public int Int => int.Parse(Next());
public long Long => long.Parse(Next());
public double Double => double.Parse(Next());
#endregion
#region LazyRead
private void scan<T>(ref T x) {
if (x is int)
__refvalue(__makeref(x), int) = int.Parse(Next());
else if (x is long)
__refvalue(__makeref(x), long) = long.Parse(Next());
else if (x is double)
__refvalue(__makeref(x), double) = double.Parse(Next());
else if (x is char)
__refvalue(__makeref(x), char) = NextChar();
else
__refvalue(__makeref(x), string) = Next();
}
public void i<T>(out T t) {
t = default(T);
scan(ref t);
}
public void i<T, TU>(out T t, out TU u) {
i(out t);
i(out u);
}
public void i<T, TU, TV>(out T t, out TU u, out TV v) {
i(out t, out u);
i(out v);
}
public void i<T, TU, TV, TW>(out T t, out TU u, out TV v, out TW w) {
i(out t, out u);
i(out v, out w);
}
public void i<T, TU, TV, TW, TX>(out T t, out TU u, out TV v, out TW w,
out TX x) {
i(out t, out u, out v);
i(out w, out x);
}
public void i<T, TU, TV, TW, TX, TY>(out T t, out TU u, out TV v, out TW w,
out TX x, out TY y) {
i(out t, out u, out v);
i(out w, out x, out y);
}
public void ini<T>(out T[] a, int n) {
a = new T[n];
for (int i = 0; i < n; ++i)
i<T>(out a[i]);
}
public void ini<T, TU>(out T[] a, out TU[] b, int n) {
a = new T[n];
b = new TU[n];
for (int i = 0; i < n; ++i)
i<T, TU>(out a[i], out b[i]);
}
public void ini<T, TU, TV>(out T[] a, out TU[] b, out TV[] c, int n) {
a = new T[n];
b = new TU[n];
c = new TV[n];
for (var i = 0; i < n; ++i)
i<T, TU, TV>(out a[i], out b[i], out c[i]);
}
public void ini<T>(out T[,] a, int h, int w) {
a = new T[h, w];
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
i<T>(out a[i, j]);
}
#endregion
#endregion
#region OUTPUT
private readonly StreamWriter _sw = new StreamWriter(OpenStandardOutput()) {
#if DEBUG
AutoFlush = true
#else
AutoFlush = false
#endif
};
public void Flush() => Out.Flush();
public void YN(bool f) => yn(f, "YES", "NO");
public void Yn(bool f) => yn(f, "Yes", "No");
public void yn(bool f, string y = "yes",
string n = "no") => WriteLine(f ? y : n);
#endregion
public IO() { SetOut(_sw); }
}
static class Ex {
#region マクロもどき
public static Dictionary<T1, T2> MERGE<T1, T2>(Dictionary<T1, T2> xs,
Dictionary<T1, T2> ys) =>
xs.Except(xs.Join(ys, z => z.Key, z => z.Key, (a, b) => a))
.Concat(ys)
.ToDictionary(z => z.Key, z => z.Value);
public static void LOG<T>(T x, [CallerLineNumber] int line = 0) =>
Error.WriteLine($"--- LOG[{line}]: {x} ---");
public static void FOR(int a, int b, Action<int> f) => FOR(a, b, 1, f);
public static void FOR(int a, int b, int n, Action<int> f) {
for (int i = a; i < b; i += n)
f(i);
}
public static void REP(int a, Action<int> f) => FOR(0, a, f);
public static void REPEQ(int a, Action<int> f) => FOR(0, a + 1, f);
public static void FOREQ(int a, int b, Action<int> f) => FOR(a, b + 1, f);
public static void FOREQ(int a, int b, int n, Action<int> f) => FOR(a, b + 1,
n, f);
public static void
REP(int a, int b, Action<int, int> f) => REP(a, i => REP(b, j => f(i, j)));
public static void REP(int a, int b, int c, Action<int, int, int> f) =>
REP(a, i => REP(b, j => REP(c, k => f(i, j, k))));
public static void REPEQ(int a, int b, Action<int, int> f) =>
REPEQ(a, i => REPEQ(b, j => f(i, j)));
public static void REPEQ(int a, int b, int c, Action<int, int, int> f) =>
REPEQ(a, i => REPEQ(b, j => REPEQ(c, k => f(i, j, k))));
public static T MIN<T>(params T[] xs) => xs.Min();
public static T MAX<T>(params T[] xs) => xs.Max();
public static int SUM(params int[] xs) => xs.Sum();
public static long SUM(params long[] xs) => xs.Sum();
public static double SUM(params double[] xs) => xs.Sum();
public static IEnumerable<int> RANGE(int s,
int e) => Enumerable.Range(s, e - s + 1);
public static int LCM(int a, int b) => a * (b / GCD(a, b));
public static int GCD(int a, int b) => (a < b) ? GCD(b, a)
: b == 0 ? a
: GCD(b, a % b);
public static int LCM(params int[] xs) => xs.Aggregate(LCM);
public static int GCD(params int[] xs) => xs.Aggregate(GCD);
public static long LCM(long a, long b) => a * (b / GCD(a, b));
public static long GCD(long a, long b) => (a < b) ? GCD(b, a)
: b == 0L ? a
: GCD(b, a % b);
public static long LCM(params long[] xs) => xs.Aggregate(LCM);
public static long GCD(params long[] xs) => xs.Aggregate(GCD);
#endregion
#region 拡張メソッド
public static void Rep(this int x, Action<int> f) => REP(x, f);
public static void RepEq(this int x, Action<int> f) => REPEQ(x, f);
public static int ToInt(this string s) {
double n;
double.TryParse(s.TrimStart('0'), out n);
return Convert.ToInt32(n);
}
public static int ToInt(this char c) => ToInt(c.ToString());
public static int ToInt(this char[] c) => ToInt(new string(c));
public static long ToLong(this string s) {
double n;
double.TryParse(s.TrimStart('0'), out n);
return Convert.ToInt64(n);
}
public static long ToLong(this int x) => (long)x;
public static IEnumerable<long>
ToLong(this IEnumerable<int> xs) => xs.Select(x => x.ToLong());
public static long ToLong(this char c) => ToLong(c.ToString());
public static long ToLong(this char[] c) => ToLong(new string(c));
public static int ToMod(this int x, int mod = (int)(1e9 + 7)) => x % mod;
public static long ToMod(this long x, long mod = (long)(1e9 + 7)) => x % mod;
public static void Do<T>(this T x, Action<T> f) => f(x);
public static TU Then<T, TU>(this T x, Func<T, TU> f) => f(x);
public static void Fun<T>(this T[] xs, Action<int> f) => REP(xs.Length, f);
public static void Fun<T>(this T[,] xxs, Action<int, int> f) =>
REP(xxs.GetLength(0), i => REP(xxs.GetLength(1), j => f(i, j)));
public static bool IsIn<T>(this T[] xs, int i) => 0 <= i && i < xs.Length;
public static bool IsIn<T>(this T[,] xxs, int i,
int j) => 0 <= i && i < xxs.GetLength(0) && 0 <= j
&& j < xxs.GetLength(1);
public static void Iter<T>(this IEnumerable<T> xs, Action<T> f) {
foreach (var x in xs)
f(x);
}
public class IndexedItem<T> {
public int Idx;
public T Val;
public IndexedItem(int idx, T val) {
Idx = idx;
Val = val;
}
}
public static IEnumerable<IndexedItem<T>> Indexed<T>(
this IEnumerable<T> xs) => xs.Select((x, i) => new IndexedItem<T>(i, x));
public static Dictionary<long, int>
PrimeFactor(this int x) => ((long)x).PrimeFactor();
public static Dictionary<long, int> PrimeFactor(this long n) {
if (n == 1L)
return new Dictionary<long, int> { [1] = 1 };
var ret = new Dictionary<long, int>();
for (var i = 2; i <= n; ++i) {
if (!ret.ContainsKey(i))
ret[i] = 0;
while (n % i == 0) {
++ret[i];
n /= i;
}
}
return ret.Where(kp => kp.Value != 0)
.ToDictionary(kp => kp.Key, kp => kp.Value);
}
public static void Set<T>(this T[] xs, T v) => REP(xs.Length, i => xs[i] = v);
public static void Set<T>(this T[,] xxs, T v) =>
REP(xxs.GetLength(0), i => REP(xxs.GetLength(1), j => xxs[i, j] = v));
public static T[] Sort<T>(this T[] xs) {
Array.Sort(xs);
return xs;
}
public static T[] SortR<T>(this T[] xs) {
Array.Reverse(xs.Sort());
return xs;
}
public static string Pad0<T>(this T s, int n) => s.ToString().PadLeft(n, '0');
public static int RoundOff(this double v, int n) => (int)
Round(v, n - 1, MidpointRounding.AwayFromZero);
public static int RoundUp(this double v) => (int)Ceiling(v);
public static int RoundDown(this double v) => (int)Floor(v);
public static bool Odd(this int v) => (v & 1) != 0;
public static bool Odd(this long v) => (v & 1) != 0;
public static bool Eve(this int v) => !v.Odd();
public static bool Eve(this long v) => !v.Odd();
public static void Prt<T>(this T x) => WriteLine(x);
public static void Prt<T>(this T[] xs) => xs.Iter(x => WriteLine(x));
public static void Prt<T>(this List<T> xs) => xs.Iter(x => WriteLine(x));
public static void Prt<T>(this T[,] xs) => xs.GetLength(0).Rep(i => {
xs.GetLength(1).Rep(j => Write($"{xs[i, j]} "));
WriteLine();
});
public static void Prt_<T>(this T[] xs) => WriteLine(string.Join(" ", xs));
public static void Log<T>(this T x, [CallerLineNumber] int line = 0) {
#if DEBUG
Error.WriteLine($"--- LOG[{line}]: {x} ---");
#endif
}
public static void Log<T>(this T[] xs, [CallerLineNumber] int line = 0) {
#if DEBUG
Error.WriteLine($"^^^ LOG[{line}] ^^^");
xs.Iter(x => Error.WriteLine(x));
Error.WriteLine($"vvv LOG[{line}] vvv\n");
#endif
}
public static void Log<T>(this T[,] xs, [CallerLineNumber] int line = 0) {
#if DEBUG
Error.WriteLine($"^^^ LOG[{line}] ^^^");
xs.GetLength(0).Rep(i => {
xs.GetLength(1).Rep(j => Error.Write($"{xs[i, j]} "));
Error.WriteLine();
});
Error.WriteLine($"vvv LOG[{line}] vvv\n");
#endif
}
public static string Reversed(this string s) => string.Join("", s.Reverse());
public static string Repeat(this string s, int n) =>
string.Concat(Enumerable.Repeat(s, n).ToArray());
#endregion
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography.X509Certificates;
using System.Security.Permissions;
using System.Text;
using static System.Console;
using static System.Math;
using static Ex;
class AC {
/*------------------------------------------------------------------*/
private string S;
void Solve() {
io.i(out S);
io.yn(S[0] == 'A' &&
S.Substring(2, S.Length - 3).Count(c => c == 'C') == 1 &&
S.Count(c => 'a' <= c && c <= 'z') == S.Length - 2,
"AC", "WA");
}
/*------------------------------------------------------------------*/
void Test() {
//--- TEST ---//
}
public static void Main(string[] args) => new AC().Stream();
IO io = new IO();
private void Stream() {
/*
var exStdIn = new System.IO.StreamReader("stdin.txt");
SetIn(exStdIn);
Test();
*/
Solve();
io.Flush();
}
}
class IO {
#region INPUT
#region FastRead
private const int Size = 1 << 12;
private readonly Stream _stream = OpenStandardInput();
private readonly byte[] _buffer = new byte[Size];
private int _ptr = 0, _buffLen = 0;
private bool HasNextByte() {
if (_ptr < _buffLen)
return true;
_ptr = 0;
_buffLen = _stream.Read(_buffer, 0, Size);
return _buffLen > 0;
}
private byte ReadByte() {
if (HasNextByte())
return _buffer[_ptr++];
else
// inputの末尾の改行がないとerror
throw new EndOfStreamException();
}
private bool IsAscii(int c) => '!' <= c && c <= '~';
private char NextChar() {
var b = ReadByte();
while (!IsAscii(b))
b = ReadByte();
return (char)b;
}
private string Next() {
var sb = new StringBuilder();
for (var b = NextChar(); IsAscii(b); b = (char)ReadByte())
sb.Append(b);
return sb.ToString();
}
public string String => Next();
public char Char => NextChar();
public int Int => int.Parse(Next());
public long Long => long.Parse(Next());
public double Double => double.Parse(Next());
#endregion
#region LazyRead
private void scan<T>(ref T x) {
if (x is int)
__refvalue(__makeref(x), int) = int.Parse(Next());
else if (x is long)
__refvalue(__makeref(x), long) = long.Parse(Next());
else if (x is double)
__refvalue(__makeref(x), double) = double.Parse(Next());
else if (x is char)
__refvalue(__makeref(x), char) = NextChar();
else
__refvalue(__makeref(x), string) = Next();
}
public void i<T>(out T t) {
t = default(T);
scan(ref t);
}
public void i<T, TU>(out T t, out TU u) {
i(out t);
i(out u);
}
public void i<T, TU, TV>(out T t, out TU u, out TV v) {
i(out t, out u);
i(out v);
}
public void i<T, TU, TV, TW>(out T t, out TU u, out TV v, out TW w) {
i(out t, out u);
i(out v, out w);
}
public void i<T, TU, TV, TW, TX>(out T t, out TU u, out TV v, out TW w,
out TX x) {
i(out t, out u, out v);
i(out w, out x);
}
public void i<T, TU, TV, TW, TX, TY>(out T t, out TU u, out TV v, out TW w,
out TX x, out TY y) {
i(out t, out u, out v);
i(out w, out x, out y);
}
public void ini<T>(out T[] a, int n) {
a = new T[n];
for (int i = 0; i < n; ++i)
i<T>(out a[i]);
}
public void ini<T, TU>(out T[] a, out TU[] b, int n) {
a = new T[n];
b = new TU[n];
for (int i = 0; i < n; ++i)
i<T, TU>(out a[i], out b[i]);
}
public void ini<T, TU, TV>(out T[] a, out TU[] b, out TV[] c, int n) {
a = new T[n];
b = new TU[n];
c = new TV[n];
for (var i = 0; i < n; ++i)
i<T, TU, TV>(out a[i], out b[i], out c[i]);
}
public void ini<T>(out T[,] a, int h, int w) {
a = new T[h, w];
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
i<T>(out a[i, j]);
}
#endregion
#endregion
#region OUTPUT
private readonly StreamWriter _sw = new StreamWriter(OpenStandardOutput()) {
#if DEBUG
AutoFlush = true
#else
AutoFlush = false
#endif
};
public void Flush() => Out.Flush();
public void YN(bool f) => yn(f, "YES", "NO");
public void Yn(bool f) => yn(f, "Yes", "No");
public void yn(bool f, string y = "yes",
string n = "no") => WriteLine(f ? y : n);
#endregion
public IO() { SetOut(_sw); }
}
static class Ex {
#region マクロもどき
public static Dictionary<T1, T2> MERGE<T1, T2>(Dictionary<T1, T2> xs,
Dictionary<T1, T2> ys) =>
xs.Except(xs.Join(ys, z => z.Key, z => z.Key, (a, b) => a))
.Concat(ys)
.ToDictionary(z => z.Key, z => z.Value);
public static void LOG<T>(T x, [CallerLineNumber] int line = 0) =>
Error.WriteLine($"--- LOG[{line}]: {x} ---");
public static void FOR(int a, int b, Action<int> f) => FOR(a, b, 1, f);
public static void FOR(int a, int b, int n, Action<int> f) {
for (int i = a; i < b; i += n)
f(i);
}
public static void REP(int a, Action<int> f) => FOR(0, a, f);
public static void REPEQ(int a, Action<int> f) => FOR(0, a + 1, f);
public static void FOREQ(int a, int b, Action<int> f) => FOR(a, b + 1, f);
public static void FOREQ(int a, int b, int n, Action<int> f) => FOR(a, b + 1,
n, f);
public static void
REP(int a, int b, Action<int, int> f) => REP(a, i => REP(b, j => f(i, j)));
public static void REP(int a, int b, int c, Action<int, int, int> f) =>
REP(a, i => REP(b, j => REP(c, k => f(i, j, k))));
public static void REPEQ(int a, int b, Action<int, int> f) =>
REPEQ(a, i => REPEQ(b, j => f(i, j)));
public static void REPEQ(int a, int b, int c, Action<int, int, int> f) =>
REPEQ(a, i => REPEQ(b, j => REPEQ(c, k => f(i, j, k))));
public static T MIN<T>(params T[] xs) => xs.Min();
public static T MAX<T>(params T[] xs) => xs.Max();
public static int SUM(params int[] xs) => xs.Sum();
public static long SUM(params long[] xs) => xs.Sum();
public static double SUM(params double[] xs) => xs.Sum();
public static IEnumerable<int> RANGE(int s,
int e) => Enumerable.Range(s, e - s + 1);
public static int LCM(int a, int b) => a * (b / GCD(a, b));
public static int GCD(int a, int b) => (a < b) ? GCD(b, a)
: b == 0 ? a
: GCD(b, a % b);
public static int LCM(params int[] xs) => xs.Aggregate(LCM);
public static int GCD(params int[] xs) => xs.Aggregate(GCD);
public static long LCM(long a, long b) => a * (b / GCD(a, b));
public static long GCD(long a, long b) => (a < b) ? GCD(b, a)
: b == 0L ? a
: GCD(b, a % b);
public static long LCM(params long[] xs) => xs.Aggregate(LCM);
public static long GCD(params long[] xs) => xs.Aggregate(GCD);
#endregion
#region 拡張メソッド
public static void Rep(this int x, Action<int> f) => REP(x, f);
public static void RepEq(this int x, Action<int> f) => REPEQ(x, f);
public static int ToInt(this string s) {
double n;
double.TryParse(s.TrimStart('0'), out n);
return Convert.ToInt32(n);
}
public static int ToInt(this char c) => ToInt(c.ToString());
public static int ToInt(this char[] c) => ToInt(new string(c));
public static long ToLong(this string s) {
double n;
double.TryParse(s.TrimStart('0'), out n);
return Convert.ToInt64(n);
}
public static long ToLong(this int x) => (long)x;
public static IEnumerable<long>
ToLong(this IEnumerable<int> xs) => xs.Select(x => x.ToLong());
public static long ToLong(this char c) => ToLong(c.ToString());
public static long ToLong(this char[] c) => ToLong(new string(c));
public static int ToMod(this int x, int mod = (int)(1e9 + 7)) => x % mod;
public static long ToMod(this long x, long mod = (long)(1e9 + 7)) => x % mod;
public static void Do<T>(this T x, Action<T> f) => f(x);
public static TU Then<T, TU>(this T x, Func<T, TU> f) => f(x);
public static void Fun<T>(this T[] xs, Action<int> f) => REP(xs.Length, f);
public static void Fun<T>(this T[,] xxs, Action<int, int> f) =>
REP(xxs.GetLength(0), i => REP(xxs.GetLength(1), j => f(i, j)));
public static bool IsIn<T>(this T[] xs, int i) => 0 <= i && i < xs.Length;
public static bool IsIn<T>(this T[,] xxs, int i,
int j) => 0 <= i && i < xxs.GetLength(0) && 0 <= j
&& j < xxs.GetLength(1);
public static void Iter<T>(this IEnumerable<T> xs, Action<T> f) {
foreach (var x in xs)
f(x);
}
public class IndexedItem<T> {
public int Idx;
public T Val;
public IndexedItem(int idx, T val) {
Idx = idx;
Val = val;
}
}
public static IEnumerable<IndexedItem<T>> Indexed<T>(
this IEnumerable<T> xs) => xs.Select((x, i) => new IndexedItem<T>(i, x));
public static Dictionary<long, int>
PrimeFactor(this int x) => ((long)x).PrimeFactor();
public static Dictionary<long, int> PrimeFactor(this long n) {
if (n == 1L)
return new Dictionary<long, int> { [1] = 1 };
var ret = new Dictionary<long, int>();
for (var i = 2; i <= n; ++i) {
if (!ret.ContainsKey(i))
ret[i] = 0;
while (n % i == 0) {
++ret[i];
n /= i;
}
}
return ret.Where(kp => kp.Value != 0)
.ToDictionary(kp => kp.Key, kp => kp.Value);
}
public static void Set<T>(this T[] xs, T v) => REP(xs.Length, i => xs[i] = v);
public static void Set<T>(this T[,] xxs, T v) =>
REP(xxs.GetLength(0), i => REP(xxs.GetLength(1), j => xxs[i, j] = v));
public static T[] Sort<T>(this T[] xs) {
Array.Sort(xs);
return xs;
}
public static T[] SortR<T>(this T[] xs) {
Array.Reverse(xs.Sort());
return xs;
}
public static string Pad0<T>(this T s, int n) => s.ToString().PadLeft(n, '0');
public static int RoundOff(this double v, int n) => (int)
Round(v, n - 1, MidpointRounding.AwayFromZero);
public static int RoundUp(this double v) => (int)Ceiling(v);
public static int RoundDown(this double v) => (int)Floor(v);
public static bool Odd(this int v) => (v & 1) != 0;
public static bool Odd(this long v) => (v & 1) != 0;
public static bool Eve(this int v) => !v.Odd();
public static bool Eve(this long v) => !v.Odd();
public static void Prt<T>(this T x) => WriteLine(x);
public static void Prt<T>(this T[] xs) => xs.Iter(x => WriteLine(x));
public static void Prt<T>(this List<T> xs) => xs.Iter(x => WriteLine(x));
public static void Prt<T>(this T[,] xs) => xs.GetLength(0).Rep(i => {
xs.GetLength(1).Rep(j => Write($"{xs[i, j]} "));
WriteLine();
});
public static void Prt_<T>(this T[] xs) => WriteLine(string.Join(" ", xs));
public static void Log<T>(this T x, [CallerLineNumber] int line = 0) {
#if DEBUG
Error.WriteLine($"--- LOG[{line}]: {x} ---");
#endif
}
public static void Log<T>(this T[] xs, [CallerLineNumber] int line = 0) {
#if DEBUG
Error.WriteLine($"^^^ LOG[{line}] ^^^");
xs.Iter(x => Error.WriteLine(x));
Error.WriteLine($"vvv LOG[{line}] vvv\n");
#endif
}
public static void Log<T>(this T[,] xs, [CallerLineNumber] int line = 0) {
#if DEBUG
Error.WriteLine($"^^^ LOG[{line}] ^^^");
xs.GetLength(0).Rep(i => {
xs.GetLength(1).Rep(j => Error.Write($"{xs[i, j]} "));
Error.WriteLine();
});
Error.WriteLine($"vvv LOG[{line}] vvv\n");
#endif
}
public static string Reversed(this string s) => string.Join("", s.Reverse());
public static string Repeat(this string s, int n) =>
string.Concat(Enumerable.Repeat(s, n).ToArray());
#endregion
}
|
[["-", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203], ["+", 205, 213, 3, 4, 0, 28, 0, 16, 12, 203]]
| 8
| 3,737
| 2
|
using System;
class Program {
static void Main() {
string s = Console.ReadLine();
int pos = 0;
bool flag = false;
for (int i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C' && flag == true) {
flag = false;
break;
}
if (s[i] == 'C') {
flag = true;
pos = i;
}
}
if (s[0] == 'A' && flag == true)
flag = true;
if (flag) {
for (int i = 1; i < s.Length; i++) {
if (char.IsUpper(s[i]) == true && i != pos) {
flag = false;
break;
}
}
}
if (flag)
Console.WriteLine("AC");
else
Console.WriteLine("WA");
}
}
|
using System;
class Program {
static void Main() {
string s = Console.ReadLine();
int pos = 0;
bool flag = false;
for (int i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C' && flag == true) {
flag = false;
break;
}
if (s[i] == 'C') {
flag = true;
pos = i;
}
}
if (s[0] != 'A' && flag == true)
flag = false;
if (flag) {
for (int i = 1; i < s.Length; i++) {
if (char.IsUpper(s[i]) == true && i != pos) {
flag = false;
break;
}
}
}
if (flag)
Console.WriteLine("AC");
else
Console.WriteLine("WA");
}
}
|
[["-", 8, 196, 0, 57, 15, 16, 31, 16, 17, 60], ["+", 8, 196, 0, 57, 15, 16, 31, 16, 17, 79], ["-", 0, 57, 64, 1, 0, 11, 12, 211, 0, 146], ["+", 0, 57, 64, 1, 0, 11, 12, 211, 0, 147]]
| 8
| 189
| 4
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main() {
string S = Console.ReadLine();
string OutputString;
if (S[0] != 'A') {
Console.WriteLine("WA");
return;
}
int CountC = 0;
int PlaceC = 0;
for (int i = 3; i < S.Length - 1; i++) {
if (S[i] == 'C') {
CountC++;
PlaceC = i;
}
}
if (CountC != 1) {
Console.WriteLine("WA");
return;
}
for (int i = 0; i < S.Length; i++) {
if (i == 0 || i == PlaceC) {
continue;
}
if (S[i] < 'a' || 'z' < S[i]) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
static void Main() {
string S = Console.ReadLine();
if (S[0] != 'A') {
Console.WriteLine("WA");
return;
}
int CountC = 0;
int PlaceC = 0;
for (int i = 2; i < S.Length - 1; i++) {
if (S[i] == 'C') {
CountC++;
PlaceC = i;
}
}
if (CountC != 1) {
Console.WriteLine("WA");
return;
}
for (int i = 0; i < S.Length; i++) {
if (i == 0 || i == PlaceC) {
continue;
}
if (S[i] < 'a' || 'z' < S[i]) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
|
[["-", 0, 195, 8, 196, 0, 197, 0, 198, 39, 199], ["-", 8, 196, 0, 197, 0, 198, 0, 200, 141, 22], ["-", 8, 201, 0, 195, 8, 196, 0, 197, 0, 35], ["-", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203], ["+", 0, 7, 10, 198, 0, 200, 0, 212, 0, 203]]
| 8
| 217
| 5
|
using System;
namespace ABC104.Task2 {
class Program {
static void Main(string[] args) {
var line = Console.ReadLine();
if (Check(line)) {
Console.WriteLine("AC");
} else {
Console.WriteLine("WA");
}
}
static bool Check(string s) {
long count = 0;
for (var i = 0; i < s.Length; i++) {
if (i == 0 && s[0] != 'A') {
return false;
} else if (i >= 2 && i < s.Length - 1 && s[i] == 'C') {
count++;
} else {
if (!Char.IsLower(s[i])) {
return false;
}
}
}
if (count != 1) {
return false;
}
return true;
}
}
}
|
using System;
namespace ABC104.Task2 {
class Program {
static void Main(string[] args) {
var line = Console.ReadLine();
if (Check(line)) {
Console.WriteLine("AC");
} else {
Console.WriteLine("WA");
}
}
static bool Check(string s) {
long count = 0;
for (var i = 0; i < s.Length; i++) {
if (i == 0) {
if (s[0] != 'A') {
return false;
}
} else if (i >= 2 && i < s.Length - 1 && s[i] == 'C') {
count++;
} else {
if (!Char.IsLower(s[i])) {
return false;
}
}
}
if (count != 1) {
return false;
}
return true;
}
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 98], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 25], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 24], ["+", 0, 57, 64, 196, 0, 57, 64, 196, 0, 46]]
| 8
| 179
| 6
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
int c = 0;
string i = Console.ReadLine();
string output = "AC";
if (i.Substring(0, 1) != "A")
output = "WA";
else {
int nagasa = i.Length;
string a = i.Substring(2, nagasa - 3);
if (CountChar(a, 'C') != 1)
output = "WA";
else {
char po = 'a';
// Console.WriteLine(po);
for (int f = 0; f < 26; f++) {
// Console.WriteLine(po);
c += CountChar(i, po);
po++;
}
if (po != nagasa - 2)
output = "WA";
}
}
//出力
Console.WriteLine(output);
}
public static int CountChar(string s, char c) {
return s.Length - s.Replace(c.ToString(), "").Length;
}
}
|
using System;
class Program {
static void Main(string[] args) {
// 整数の入力
int c = 0;
string i = Console.ReadLine();
string output = "AC";
if (i.Substring(0, 1) != "A")
output = "WA";
else {
int nagasa = i.Length;
string a = i.Substring(2, nagasa - 3);
if (CountChar(a, 'C') != 1)
output = "WA";
else {
char po = 'a';
// Console.WriteLine(po);
for (int f = 0; f < 26; f++) {
// Console.WriteLine(po);
c += CountChar(i, po);
po++;
}
if (c != nagasa - 2)
output = "WA";
}
}
//出力
Console.WriteLine(output);
}
public static int CountChar(string s, char c) {
return s.Length - s.Replace(c.ToString(), "").Length;
}
}
|
[["-", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22], ["+", 0, 57, 75, 196, 0, 57, 15, 16, 31, 22]]
| 8
| 200
| 2
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
string inpt = Reader.ReadLine();
string ans = "WA";
if (Judge(inpt)) {
ans = "AC";
}
Console.WriteLine(ans);
}
private bool Judge(string inpt) {
if (inpt[0] != 'A') {
return false;
}
if (inpt.Length <= 5) {
return false;
}
int cCount = 0;
for (int i = 2; i <= inpt.Length - 2; i++) {
if (inpt[i] == 'C') {
cCount++;
}
}
if (cCount != 1) {
return false;
}
for (int i = 0; i < inpt.Length; i++) {
if (inpt[i] == 'A') {
if (i != 0) {
return false;
}
} else if (inpt[i] == 'C') {
if (i < 2 || i > inpt.Length - 2) {
return false;
}
} else if (inpt[i] >= 'a' && inpt[i] <= 'z') {
continue;
} else {
return false;
}
}
return true;
}
public class Reader {
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
Atcoder
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
public class Program {
public void Proc() {
string inpt = Reader.ReadLine();
string ans = "WA";
if (Judge(inpt)) {
ans = "AC";
}
Console.WriteLine(ans);
}
private bool Judge(string inpt) {
if (inpt[0] != 'A') {
return false;
}
if (inpt.Length < 4) {
return false;
}
int cCount = 0;
for (int i = 2; i <= inpt.Length - 2; i++) {
if (inpt[i] == 'C') {
cCount++;
}
}
if (cCount != 1) {
return false;
}
for (int i = 0; i < inpt.Length; i++) {
if (inpt[i] == 'A') {
if (i != 0) {
return false;
}
} else if (inpt[i] == 'C') {
if (i < 2 || i > inpt.Length - 2) {
return false;
}
} else if (inpt[i] >= 'a' && inpt[i] <= 'z') {
continue;
} else {
return false;
}
}
return true;
}
public class Reader {
static StringReader sr;
public static bool IsDebug = false;
public static string ReadLine() {
if (IsDebug) {
if (sr == null) {
sr = new StringReader(InputText.Trim());
}
return sr.ReadLine();
} else {
return Console.ReadLine();
}
}
private static string InputText = @"
AtCo
";
}
public static void Main(string[] args) {
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
|
[["-", 0, 195, 8, 196, 0, 57, 15, 16, 17, 19], ["-", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 57, 15, 16, 12, 203], ["-", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258], ["+", 0, 124, 0, 198, 0, 200, 0, 212, 0, 258]]
| 8
| 385
| 6
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AtCoder_Project_CSharp {
class Program {
static void Main(string[] args) {
var s = (Console.ReadLine());
var alphabet = new HashSet<int>(Enumerable.Range('a', 26));
if (s[0] == 'A') {
for (int i = 2; i < s.Length - 2; i++) {
if (s[i] == 'C') {
bool flag = false;
for (int j = 1; j < s.Length; j++) {
if (i == j)
continue;
if (!alphabet.Contains(s[j])) {
flag = true;
break;
}
}
if (!flag) {
Console.WriteLine("AC");
return;
}
}
}
}
Console.WriteLine("WA");
}
}
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace AtCoder_Project_CSharp {
class Program {
static void Main(string[] args) {
var s = (Console.ReadLine());
var alphabet = new HashSet<int>(Enumerable.Range('a', 26));
if (s[0] == 'A') {
for (int i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C') {
bool flag = false;
for (int j = 1; j < s.Length; j++) {
if (i == j)
continue;
if (!alphabet.Contains(s[j])) {
flag = true;
break;
}
}
if (!flag) {
Console.WriteLine("AC");
return;
}
}
}
}
Console.WriteLine("WA");
}
}
}
|
[["-", 64, 196, 0, 7, 15, 16, 12, 16, 12, 203], ["+", 64, 196, 0, 7, 15, 16, 12, 16, 12, 203]]
| 8
| 198
| 2
|
using System;
using System.Linq;
namespace ABC104B {
internal class Program {
public static void Main(string[] args) {
string s = ConsoleInput.String();
if (s[0] != 'A') {
Console.WriteLine("WA");
return;
}
int cPos = 0;
for (int i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C') {
if (cPos != 0) {
Console.WriteLine("WA");
return;
}
cPos = i;
}
}
if (cPos == 0) {
Console.WriteLine("WA");
return;
}
string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (int i = 1; i < s.Length; i++) {
if (i == cPos) {
continue;
}
if (!chars.Contains(s[i])) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
internal static class ConsoleInput {
public static string String() { return Console.ReadLine(); }
public static int Int() { return int.Parse(Console.ReadLine()); }
public static int[] IntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long Long() { return long.Parse(Console.ReadLine()); }
public static long[] LongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static double[] DoubleArray() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
}
|
using System;
using System.Linq;
namespace ABC104B {
internal class Program {
public static void Main(string[] args) {
string s = ConsoleInput.String();
if (s[0] != 'A') {
Console.WriteLine("WA");
return;
}
int cPos = 0;
for (int i = 2; i < s.Length - 1; i++) {
if (s[i] == 'C') {
if (cPos != 0) {
Console.WriteLine("WA");
return;
}
cPos = i;
}
}
if (cPos == 0) {
Console.WriteLine("WA");
return;
}
string chars = "abcdefghijklmnopqrstuvwxyz";
for (int i = 1; i < s.Length; i++) {
if (i == cPos) {
continue;
}
if (!chars.Contains(s[i])) {
Console.WriteLine("WA");
return;
}
}
Console.WriteLine("AC");
}
}
internal static class ConsoleInput {
public static string String() { return Console.ReadLine(); }
public static int Int() { return int.Parse(Console.ReadLine()); }
public static int[] IntArray() {
return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
}
public static long Long() { return long.Parse(Console.ReadLine()); }
public static long[] LongArray() {
return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
}
public static double[] DoubleArray() {
return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
}
}
}
|
[["-", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222], ["+", 0, 198, 0, 200, 0, 212, 0, 5, 0, 222]]
| 8
| 378
| 2
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace C {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var dg = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var d = dg[0];
var g = dg[1];
var pi = new int[d];
var ci = new int[d];
var answer = (int)1e9;
for (var i = 0; i < d; i++) {
var pc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
pi[i] = pc[0];
ci[i] = pc[1];
}
for (var bit = 0; bit < (1 << d); bit++) {
var score = 0;
var num = 0;
var maxIndex = 0;
for (var i = 0; i < d; i++) {
if (((bit >> i) & 1) == 1) {
score += 100 * (i + 1) * pi[i] + ci[i];
num += pi[i];
} else {
maxIndex = i;
}
}
if (score < g) {
var max = 100 * (maxIndex + 1);
var need = (g - score + max) / max;
if (need > pi[maxIndex])
continue;
num += need - 1;
}
answer = Math.Min(answer, num);
}
Console.WriteLine(answer);
}
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace C {
public class Program {
static void Main(string[] args) {
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
Solve();
Console.Out.Flush();
}
public static void Solve() {
var dg = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
var d = dg[0];
var g = dg[1];
var pi = new int[d];
var ci = new int[d];
var answer = (int)1e9;
for (var i = 0; i < d; i++) {
var pc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
pi[i] = pc[0];
ci[i] = pc[1];
}
for (var bit = 0; bit < (1 << d); bit++) {
var score = 0;
var num = 0;
var maxIndex = 0;
for (var i = 0; i < d; i++) {
if (((bit >> i) & 1) == 1) {
score += 100 * (i + 1) * pi[i] + ci[i];
num += pi[i];
} else {
maxIndex = i;
}
}
if (score < g) {
var max = 100 * (maxIndex + 1);
var need = (g - score + max - 1) / max;
if (need >= pi[maxIndex])
continue;
num += need;
}
answer = Math.Min(answer, num);
}
Console.WriteLine(answer);
}
}
}
|
[["+", 0, 212, 0, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 212, 0, 16, 31, 23, 0, 16, 12, 203], ["-", 0, 57, 64, 196, 0, 57, 15, 16, 17, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 16, 17, 20], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 203]]
| 8
| 398
| 6
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = int.Parse(Console.ReadLine());
int[] dg = Console.ReadLine().Split().Select(int.Parse).ToArray();
var d = dg[0];
var g = dg[1];
int[] p = new int[d];
int[] c = new int[d];
for (int i = 0; i < d; i++) {
int[] pc = Console.ReadLine().Split().Select(int.Parse).ToArray();
p[i] = pc[0];
c[i] = pc[1];
}
// 0(false) = 解かない
// 1(true) = 完全に解く
// bit探索(bit全探索)
long ans = long.MaxValue;
for (int x = 0; x < Math.Pow(2, d); x++) {
var array = new bool[d];
// 右からk桁目を取り出す
for (int k = 0; k < d; k++) {
var y = (x >> k) & 1;
if (y == 1)
array[k] = true;
}
long tmp = 0;
long count1 = 0;
long last = 0;
for (int k = 0; k < d; k++) {
if (array[k]) {
tmp += (k + 1) * 100 * p[k] + c[k];
count1 += p[k];
} else {
last = k;
}
}
// g以下の場合は中途半端に解く
long count2 = 0;
while (tmp < g && count2 < p[last]) {
tmp += (last + 1) * 100;
count2++;
}
if (tmp > d) {
ans = Math.Min(ans, count1 + count2);
}
}
// 出力
Console.WriteLine(ans);
}
}
|
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
class Program {
static void Main(string[] args) {
// 入力
// var s = Console.ReadLine();
// var n = int.Parse(Console.ReadLine());
int[] dg = Console.ReadLine().Split().Select(int.Parse).ToArray();
var d = dg[0];
var g = dg[1];
int[] p = new int[d];
int[] c = new int[d];
for (int i = 0; i < d; i++) {
int[] pc = Console.ReadLine().Split().Select(int.Parse).ToArray();
p[i] = pc[0];
c[i] = pc[1];
}
// 0(false) = 解かない
// 1(true) = 完全に解く
// bit探索(bit全探索)
long ans = long.MaxValue;
for (int x = 0; x < Math.Pow(2, d); x++) {
var array = new bool[d];
// 右からk桁目を取り出す
for (int k = 0; k < d; k++) {
var y = (x >> k) & 1;
if (y == 1)
array[k] = true;
}
long tmp = 0;
long count1 = 0;
long last = 0;
for (int k = 0; k < d; k++) {
if (array[k]) {
tmp += (k + 1) * 100 * p[k] + c[k];
count1 += p[k];
} else {
last = k;
}
}
// g以下の場合は中途半端に解く
long count2 = 0;
while (tmp < g && count2 < p[last]) {
tmp += (last + 1) * 100;
count2++;
}
if (tmp >= g) {
ans = Math.Min(ans, count1 + count2);
}
}
// 出力
Console.WriteLine(ans);
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 17, 47], ["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 17, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 22]]
| 8
| 389
| 4
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace ABC104C {
class Program {
static void Solve(Input input) {
var d = input.NextInt();
var g = input.NextInt();
var pros = new Tuple<int, int, int>[d];
for (int i = 0; i < d; i++) {
var p = input.NextInt();
var c = input.NextInt();
pros[i] = new Tuple<int, int, int>(100 * (i + 1), p, c);
}
var allSolve = pros.Select(x => new { Point = x.Item1 * x.Item2 + x.Item3,
Count = x.Item2 })
.ToArray();
var n = 1 << allSolve.Count();
var min = int.MaxValue;
for (int i = 0; i < n; i++) {
var sum = 0;
var count = 0;
var res = Enumerable.Range(0, d).ToList();
for (int j = 0; j < n; j++) {
if (((i >> j) & 1) != 0) {
sum += allSolve[j].Point;
count += allSolve[j].Count;
res.Remove(j);
}
}
if (sum < g && res.Any()) {
// 未使用の問題で、一番点数が高いものを使う
var j = res.Last();
if (sum + pros[j].Item1 * (pros[j].Item2 - 1) >= g) {
var r = g - sum;
var c = (r + pros[j].Item1 - 1) / pros[j].Item1;
count += c;
sum += pros[j].Item1 * c;
}
}
if (sum >= g)
min = Math.Min(min, count);
}
Console.WriteLine(min);
}
#region Main
public static void Main(string[] args) {
// 出力が少ないときはこれをセットする方が時間かかるけれど
// その場合は出力がボトルネックになっていないので、まあ良しとする
var needsFlushOutput = true;
if (needsFlushOutput) {
// 細かく出力しないようにする
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// 通常は引数無しで、ファイルから読み出したい場合はpath指定する
var input = new Input();
// 仮想的に標準入力をセットする
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
#endregion
#region Competitive Template
#pragma warning disable CS0414
static readonly int MOD = (int)1e9 + 7;
#pragma warning restore CS0414
class Input {
// 変な改行コードがたまに混じっているので、一応セパレート指定する
// スペース単独指定の方がもちろん早い
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// 特定のファイルから読み出したい場合はpath指定する
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// 指定個数queueにたまるまでenqueueし続ける
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// n個の要素をparseして、それぞれにoffsetをaddした配列を返す
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vでfillされたT[d1][d2]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vでfillされたT[d1][d2][d3]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace ABC104C {
class Program {
static void Solve(Input input) {
var d = input.NextInt();
var g = input.NextInt();
var pros = new Tuple<int, int, int>[d];
for (int i = 0; i < d; i++) {
var p = input.NextInt();
var c = input.NextInt();
pros[i] = new Tuple<int, int, int>(100 * (i + 1), p, c);
}
var allSolve = pros.Select(x => new { Point = x.Item1 * x.Item2 + x.Item3,
Count = x.Item2 })
.ToArray();
var n = 1 << allSolve.Count();
var min = int.MaxValue;
for (int i = 0; i < n; i++) {
var sum = 0;
var count = 0;
var res = Enumerable.Range(0, d).ToList();
for (int j = 0; j < allSolve.Count(); j++) {
if (((i >> j) & 1) != 0) {
sum += allSolve[j].Point;
count += allSolve[j].Count;
res.Remove(j);
}
}
if (sum < g && res.Any()) {
// 未使用の問題で、一番点数が高いものを使う
var j = res.Last();
if (sum + pros[j].Item1 * (pros[j].Item2 - 1) >= g) {
var r = g - sum;
var c = (r + pros[j].Item1 - 1) / pros[j].Item1;
count += c;
sum += pros[j].Item1 * c;
}
}
if (sum >= g)
min = Math.Min(min, count);
}
Console.WriteLine(min);
}
#region Main
public static void Main(string[] args) {
// 出力が少ないときはこれをセットする方が時間かかるけれど
// その場合は出力がボトルネックになっていないので、まあ良しとする
var needsFlushOutput = true;
if (needsFlushOutput) {
// 細かく出力しないようにする
var sw =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
Console.SetOut(sw);
}
// 通常は引数無しで、ファイルから読み出したい場合はpath指定する
var input = new Input();
// 仮想的に標準入力をセットする
// input.SetText("");
Solve(input);
Console.Out.Flush();
}
#endregion
#region Competitive Template
#pragma warning disable CS0414
static readonly int MOD = (int)1e9 + 7;
#pragma warning restore CS0414
class Input {
// 変な改行コードがたまに混じっているので、一応セパレート指定する
// スペース単独指定の方がもちろん早い
static readonly char[] separator = { ' ', '\r', '\n' };
Queue<string> q { get; set; }
StreamReader sr;
/// <summary>
/// 特定のファイルから読み出したい場合はpath指定する
/// </summary>
/// <param name="path"></param>
public Input(string path = "") {
q = new Queue<string>();
if (string.IsNullOrEmpty(path)) {
sr = new StreamReader(Console.OpenStandardInput());
} else {
sr = new StreamReader(path);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="items"></param>
public void SetText(IEnumerable<string> items) {
foreach (var item in items) {
SetText(item);
}
}
/// <summary>
/// 入力予約
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public bool SetText(string s) {
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
return true;
}
/// <summary>
/// 内部queueに入力からの値をsplitして格納する
/// </summary>
/// <returns></returns>
bool read() {
var s = sr.ReadLine();
if (s == null)
return false;
foreach (var elem in s.Trim().Split(
separator, StringSplitOptions.RemoveEmptyEntries)) {
q.Enqueue(elem);
}
if (!q.Any())
return read();
return true;
}
/// <summary>
/// 次のstringを一つ読み込む
/// </summary>
/// <returns></returns>
public string Next() {
if (!q.Any()) {
if (!read()) {
return "";
}
}
return q.Dequeue();
}
/// <summary>
/// 指定個数queueにたまるまでenqueueし続ける
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
bool accumulate(int n) {
while (q.Count() < n) {
if (!read())
return false;
}
return true;
}
public int NextInt() => int.Parse(Next());
public long NextLong() => long.Parse(Next());
public double NextDouble() => double.Parse(Next());
/// <summary>
/// n個の要素をparseして、それぞれにoffsetをaddした配列を返す
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="n"></param>
/// <param name="offset"></param>
/// <param name="parse"></param>
/// <param name="add"></param>
/// <returns></returns>
T[] NextT<T>(int n, T offset, Func<string, T> parse, Func<T, T, T> add) {
if (!accumulate(n))
return null;
var a = new T[n];
for (int i = 0; i < n; i++)
a[i] = add(parse(q.Dequeue()), offset);
return a;
}
public string[] Next(int n) => NextT(n, "", x => x, (x, y) => x);
public int[] NextInt(int n, int offset = 0) => NextT(n, offset, int.Parse,
(x, y) => x + y);
public long[] NextLong(int n, long offset = 0) => NextT(n, offset,
long.Parse,
(x, y) => x + y);
public double[] NextDouble(int n, double offset = 0.0) =>
NextT(n, offset, double.Parse, (x, y) => x + y);
}
static class Utils {
public static void Print<T>(IEnumerable<T> ie, string sep = " ") =>
Console.WriteLine(string.Join(sep, ie));
public static void Print<T>(params T[] objs) => Print(objs);
public static T Max<T>(params T[] objs) => objs.Max();
public static T Min<T>(params T[] objs) => objs.Min();
public static void Swap<T>(ref T x, ref T y)
where T : struct {
var t = x;
x = y;
y = t;
}
public static void Swap<T>(IList<T> list, int i, int j)
where T : struct {
var t = list[i];
list[i] = list[j];
list[j] = t;
}
/// <summary>
/// vでfillされたT[d1][d2]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][] Create2DArray<T>(int d1, int d2, T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(v, d2).ToArray())
.ToArray();
}
/// <summary>
/// vでfillされたT[d1][d2][d3]配列を作成する
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <param name="d3"></param>
/// <param name="v"></param>
/// <returns></returns>
public static T[][][] Create3DArray<T>(int d1, int d2, int d3,
T v = default(T)) {
return Enumerable.Repeat(0, d1)
.Select(_ => Enumerable.Repeat(0, d2)
.Select(__ => Enumerable.Repeat(v, d3).ToArray())
.ToArray())
.ToArray();
}
}
#endregion
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 205, 22], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 0, 131], ["+", 0, 7, 15, 16, 12, 213, 63, 214, 141, 22], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 24], ["+", 0, 7, 15, 16, 12, 213, 3, 4, 0, 25]]
| 8
| 1,498
| 6
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
var dg = Console.ReadLine().Split().Select(int.Parse).ToArray();
var d = dg[0];
var g = dg[1];
var pc =
Enumerable.Repeat(0, d)
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
int res = int.MaxValue;
for (int i = 0; i < (1 << d); i++) {
int remain = g;
int count = 0;
int max = -1;
for (int j = 0; j < d; j++) {
if (((i >> j) & 1) == 1) {
remain -= (j + 1) * pc[j][0] * 100 + pc[j][1];
count += pc[j][0];
} else
max = j;
}
if (max == 0) {
if (remain <= 0)
res = Min(res, count);
continue;
}
if (remain > ((max + 1) * 100) * pc[max][0])
continue;
count += (int)Ceiling((double)Max(0, remain) / ((max + 1) * 100));
res = Min(res, count);
}
Console.WriteLine(res);
}
}
|
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
static class P {
static void Main() {
var dg = Console.ReadLine().Split().Select(int.Parse).ToArray();
var d = dg[0];
var g = dg[1];
var pc =
Enumerable.Repeat(0, d)
.Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray())
.ToArray();
int res = int.MaxValue;
for (int i = 0; i < (1 << d); i++) {
int remain = g;
int count = 0;
int max = -1;
for (int j = 0; j < d; j++) {
if (((i >> j) & 1) == 1) {
remain -= (j + 1) * pc[j][0] * 100 + pc[j][1];
count += pc[j][0];
} else
max = j;
}
if (max == -1) {
if (remain <= 0)
res = Min(res, count);
continue;
}
if (remain > ((max + 1) * 100) * pc[max][0])
continue;
count += (int)Ceiling((double)Max(0, remain) / ((max + 1) * 100));
res = Min(res, count);
}
Console.WriteLine(res);
}
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 33], ["+", 8, 196, 0, 57, 15, 16, 12, 241, 0, 203]]
| 8
| 400
| 3
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
const int MOD = 1000000007;
const int INF = 1 << 30;
static void Main(string[] args) { Solve(); }
static long GCD(long x, long y) {
if (y == 0)
return x;
return GCD(y, x % y);
}
static long LCM(long x, long y) { return x * y / GCD(x, y); }
static int keta(int x) {
string s = x.ToString();
return s[s.Length - 1] - '0';
}
static void Solve() {
Scan sc = new Scan();
write wr = new write();
long ans = INF;
var x = sc.intarr;
int D = x[0];
int G = x[1];
long[] p = new long[D];
long[] c = new long[D];
for (int i = 0; i < D; ++i) {
var y = sc.intarr;
p[i] = y[0];
c[i] = y[1];
}
for (int bit = 0; bit < (1 << D); ++bit) {
long sum = 0;
long num = 0;
for (int i = 0; i < D; ++i) {
if ((bit & (1 << i)) != 1) {
sum += c[i] + p[i] * 100 * (i + 1);
num += p[i];
}
}
if (sum >= G)
ans = Math.Min(ans, num);
else {
for (int i = D - 1; i >= 0; --i) {
if ((bit & (1 << i)) != 1)
continue;
for (int k = 0; k < p[i]; ++k) {
if (sum >= G)
break;
sum += 100 * (i + 1);
++num;
}
}
ans = Math.Min(ans, num);
}
}
wr.wri(ans);
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => str.ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program {
const int MOD = 1000000007;
const int INF = 1 << 30;
static void Main(string[] args) { Solve(); }
static long GCD(long x, long y) {
if (y == 0)
return x;
return GCD(y, x % y);
}
static long LCM(long x, long y) { return x * y / GCD(x, y); }
static int keta(int x) {
string s = x.ToString();
return s[s.Length - 1] - '0';
}
static void Solve() {
Scan sc = new Scan();
write wr = new write();
long ans = INF;
var x = sc.intarr;
int D = x[0];
int G = x[1];
long[] p = new long[D];
long[] c = new long[D];
for (int i = 0; i < D; ++i) {
var y = sc.intarr;
p[i] = y[0];
c[i] = y[1];
}
for (int bit = 0; bit < (1 << D); ++bit) {
long sum = 0;
long num = 0;
for (int i = 0; i < D; ++i) {
if ((bit & (1 << i)) != 0) {
sum += c[i] + p[i] * 100 * (i + 1);
num += p[i];
}
}
if (sum >= G)
ans = Math.Min(ans, num);
else {
for (int i = D - 1; i >= 0; --i) {
if ((bit & (1 << i)) != 0)
continue;
for (int k = 0; k < p[i]; ++k) {
if (sum >= G)
break;
sum += 100 * (i + 1);
++num;
}
}
ans = Math.Min(ans, num);
}
}
wr.wri(ans);
}
}
class Scan {
public string str => Console.ReadLine();
public string[] strarr => str.Split(' ');
public long[] longarr => strarr.Select(long.Parse).ToArray();
public int[] intarr => strarr.Select(int.Parse).ToArray();
public char[] chararr => str.ToArray();
}
class write {
public void wri<Type>(Type x) { Console.WriteLine(x); }
}
|
[["-", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203], ["+", 0, 7, 8, 196, 0, 57, 15, 16, 12, 203]]
| 8
| 566
| 4
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.