当前位置: 首页>>代码示例>>C#>>正文


C# Scanner.NextInt方法代码示例

本文整理汇总了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);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:34,代码来源:192.cs

示例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]);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:28,代码来源:A194.cs

示例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);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:34,代码来源:181.cs

示例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);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:30,代码来源:A196.cs

示例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);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:32,代码来源:A167.cs

示例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);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:32,代码来源:197.cs

示例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);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:59,代码来源:193.cs

示例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));
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:8,代码来源:182.cs

示例9: Run

    void Run()
    {
        Scanner input = new Scanner(Console.In);

        int a = input.NextInt();
        int s = input.NextInt();

        Console.WriteLine(2*s-a);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:9,代码来源:210.cs

示例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));
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:11,代码来源:A141.cs

示例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();
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:11,代码来源:A144.cs

示例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;
 }
开发者ID:pandeyiyer,项目名称:acm,代码行数:11,代码来源:A165.cs

示例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]));
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:12,代码来源:A159.cs

示例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);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:14,代码来源:211.cs

示例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]);
    }
开发者ID:pandeyiyer,项目名称:acm,代码行数:14,代码来源:A149.cs


注:本文中的Scanner.NextInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。