本文整理汇总了C#中Scanner.NextInt方法的典型用法代码示例。如果您正苦于以下问题:C# Scanner.NextInt方法的具体用法?C# Scanner.NextInt怎么用?C# Scanner.NextInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.NextInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
void Run()
{
Scanner input = new Scanner(Console.In);
N = input.NextInt();
mat = new int[N, N];
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
mat[i, j] = input.NextInt();
int res = 0;
for (int y1 = 0; y1 < N; y1++) {
for (int x1 = 0; x1 < N; x1++) {
int c = mat[y1, x1];
for (int y2 = y1; y2 < N; y2++) {
for (int x2 = (y1 == y2 ? x1 + 1 : 0); x2 < N; x2++) {
if (mat[y2, x2] != c) continue;
int y3 = y2 + (x2 - x1);
int x3 = x2 + (y1 - y2);
if (y3 < 0 || y3 >= N || x3 < 0 || x3 >= N || mat[y3, x3] != c) continue;
int y4 = y1 + (x2 - x1);
int x4 = x1 + (y1 - y2);
if (y4 < 0 || y4 >= N || x4 < 0 || x4 >= N || mat[y4, x4] != c) continue;
res++;
}
}
}
}
Console.WriteLine(res/2);
}
示例2: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
int[,] a = new int[N, N];
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
a[i, j] = input.NextInt();
int[] dp = new int[1 << N];
dp[0] = 0;
for (int mask = 1; mask < (1 << N); ++mask) {
int i = -1;
for (int j = 0; j < N; j++)
i += (mask >> j) & 1;
dp[mask] = int.MaxValue;
for (int j = 0; j < N; j++)
if ((mask & (1 << j)) != 0) {
int t = a[i, j] + dp[mask ^ (1 << j)];
if (t < dp[mask]) dp[mask] = t;
}
}
Console.WriteLine(dp[(1 << N) - 1]);
}
示例3: Run
public void Run()
{
Scanner input = new Scanner(Console.In);
double height = input.NextDouble();
double[] x = new double[200];
double[] y = new double[200];
int n = input.NextInt() + 1;
for (int i = 0; i < n; i++)
{
x[i] = input.NextDouble();
y[i] = input.NextDouble();
}
int m = input.NextInt() + 1;
n += m;
for (int i = 1; i <= m; i++)
{
x[n - i] = input.NextDouble();
y[n - i] = input.NextDouble();
}
double area = 0;
for (int i = 0; i < n; i++)
{
int j = (i + 1) % n;
area += x[i] * y[j] - x[j] * y[i];
}
double volume = Math.Abs(area) / 2.0 * height;
Console.WriteLine("{0:0.00}", volume);
}
示例4: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int A = input.NextInt();
int B = input.NextInt();
int D = input.NextInt();
bool[] sieve = new bool[B + 10];
sieve[0] = sieve[1] = true;
for (int i = 2; i * i <= B; ++i) {
if (!sieve[i]) {
for (int j = i * i; j <= B; j += i)
sieve[j] = true;
}
}
int res = 0;
for (int i = A; i <= B; ++i) {
if (!sieve[i]) {
int t = i;
while (t > 0) {
if (t % 10 == D) { res++; break; }
t /= 10;
}
}
}
Console.WriteLine(res);
}
示例5: Run
void Run()
{
Scanner input = new Scanner(Console.In);
N = input.NextInt();
value = new int[N + 1];
for (int i = 1; i <= N; i++)
value[i] = input.NextInt();
kid = new int[N + 1];
sib = new int[N + 1];
parent = new int[N + 1];
for (int i = 1; i < N; i++) {
int x = input.NextInt();
int p = input.NextInt();
sib[x] = kid[p];
kid[p] = x;
parent[x] = p;
}
int root = 0;
for (int i = 1; i <= N; i++)
if (parent[i] == 0) root = i;
memo = new int[N + 1, 2];
got = new bool[N + 1, 2];
int res = Math.Max(vertCov(root, 0), vertCov(root, 1));
Console.WriteLine(res);
}
示例6: Run
void Run()
{
Scanner input = new Scanner(Console.In);
long A = input.NextInt();
long B = input.NextInt();
int N = input.NextInt();
Bignum a = new Bignum(0);
Bignum b = new Bignum(0);
Bignum one = new Bignum(1);
int last = 0;
for (int i = 0; i < N; i++) {
while (A % 2 == 0 && B % 2 == 0) { A /= 2; B /= 2; }
if (A > B || (A == B && last == 0)) {
B *= 2;
last = 0;
a.Add(a);
a.Add(one);
} else {
A *= 2;
last = 1;
b.Add(b);
b.Add(one);
}
}
a.Add(b);
Console.WriteLine(a);
}
示例7: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
Point[,] r = new Point[N, 2];
for (int i = 0; i < N; i++) {
r[i, 0].x = input.NextInt();
r[i, 0].y = input.NextInt();
r[i, 1].x = input.NextInt();
r[i, 1].y = input.NextInt();
if (r[i, 0].CompareTo(r[i, 1]) == 0) {
i--;
N--;
}
}
while (true) {
bool changed = false;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (mergeSegments(ref r[i, 0], ref r[i, 1], r[j, 0], r[j, 1])) {
for (int k = j + 1; k < N; k++) {
r[k - 1, 0] = r[k, 0];
r[k - 1, 1] = r[k, 1];
}
N--;
changed = true;
break;
}
}
}
if (!changed) break;
}
//for (int i = 0; i < N; i++)
// Console.WriteLine("Segment {0}: {1} -- {2}", i+1, r[i, 0], r[i, 1]);
int res = 0;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (!segCross(r[i, 0], r[i, 1], r[j, 0], r[j, 1])) continue;
for (int k = j + 1; k < N; k++) {
if (!segCross(r[i, 0], r[i, 1], r[k, 0], r[k, 1])) continue;
if (!segCross(r[j, 0], r[j, 1], r[k, 0], r[k, 1])) continue;
if (coincident(r[i, 0], r[i, 1], r[j, 0], r[j, 1], r[k, 0], r[k, 1]))
continue;
res++;
}
}
}
Console.WriteLine(res);
}
示例8: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt() - 1;
int M = input.NextInt() - 1;
Console.WriteLine(solve(N, M));
}
示例9: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int a = input.NextInt();
int s = input.NextInt();
Console.WriteLine(2*s-a);
}
示例10: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
int[] a = new int[N];
for (int i = 0; i < N; i++)
a[i] = input.NextInt();
Console.WriteLine(solve(a));
}
示例11: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int M = input.NextInt();
int K = input.NextInt();
for (int x = K % 2; x <= K; x += 2)
Console.Write("{0} ", x * M);
Console.WriteLine();
}
示例12: ReadConfig
int[] ReadConfig(Scanner input, int N)
{
int[] v = new int[N];
for (int i = 0; i < N; i++) {
int y = input.NextInt();
int x = input.NextInt();
v[i] = (y - 1) * 4 + (x - 1);
}
Array.Sort(v);
return v;
}
示例13: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
int[] a = new int[N];
for (int i = 0; i < N; i++)
a[i] = input.NextInt();
for (int i = (N+1)/2, j = N, k = 0; k < N; k++)
Console.WriteLine((k % 2 == 0 ? a[--i] : a[--j]));
}
示例14: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
int K = input.NextInt();
int res = Math.Min(N, (K + 4699) / 4700);
K = Math.Max(0, K - 4700 * res);
res += (K + 699) / 700;
Console.WriteLine(res);
}
示例15: Run
void Run()
{
Scanner input = new Scanner(Console.In);
int N = input.NextInt();
int K = input.NextInt();
long[,] tab = new long[64, 64];
tab[0, 0] = 1;
for (int k = 1; k <= K; k++)
for (int n = 1; n <= 62; n++)
tab[n, k] = tab[n - 1, k - 1] + tab[n + 1, k - 1];
Console.WriteLine(tab[N, K]);
}