結果

問題 No.1070 Missing a space
ユーザー mbanmban
提出日時 2020-06-05 21:22:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 54 ms / 1,000 ms
コード長 1,779 bytes
コンパイル時間 2,632 ms
コンパイル使用メモリ 107,300 KB
実行使用メモリ 22,528 KB
最終ジャッジ日時 2023-08-22 14:01:49
合計ジャッジ時間 3,671 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
22,408 KB
testcase_01 AC 52 ms
20,436 KB
testcase_02 AC 53 ms
22,528 KB
testcase_03 AC 53 ms
20,516 KB
testcase_04 AC 54 ms
22,456 KB
testcase_05 AC 53 ms
20,480 KB
testcase_06 AC 53 ms
20,636 KB
testcase_07 AC 53 ms
22,440 KB
testcase_08 AC 53 ms
22,460 KB
testcase_09 AC 53 ms
20,344 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        string s = sc.Next();

        int cnt = 0;
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i] != '0') cnt++;
        }

        Console.WriteLine(cnt);
    }

    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