結果

問題 No.2607 Add One Digit
ユーザー heno239heno239
提出日時 2024-02-02 18:42:56
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 75 ms / 1,000 ms
コード長 3,064 bytes
コンパイル時間 6,813 ms
コンパイル使用メモリ 158,688 KB
実行使用メモリ 180,100 KB
最終ジャッジ日時 2024-02-02 18:43:05
合計ジャッジ時間 9,604 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
32,804 KB
testcase_01 AC 71 ms
32,804 KB
testcase_02 AC 71 ms
32,804 KB
testcase_03 AC 72 ms
32,804 KB
testcase_04 AC 73 ms
32,804 KB
testcase_05 AC 73 ms
32,804 KB
testcase_06 AC 74 ms
32,804 KB
testcase_07 AC 73 ms
32,804 KB
testcase_08 AC 74 ms
32,804 KB
testcase_09 AC 73 ms
32,804 KB
testcase_10 AC 72 ms
32,804 KB
testcase_11 AC 74 ms
32,804 KB
testcase_12 AC 75 ms
32,804 KB
testcase_13 AC 72 ms
32,804 KB
testcase_14 AC 73 ms
32,804 KB
testcase_15 AC 71 ms
32,804 KB
testcase_16 AC 72 ms
32,804 KB
testcase_17 AC 73 ms
32,804 KB
testcase_18 AC 73 ms
32,804 KB
testcase_19 AC 71 ms
180,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (106 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
/home/judge/data/code/Main.cs(25,19): warning CS8981: 型名 'perm' には、小文字の ASCII 文字のみが含まれています。このような名前は、プログラミング言語用に予約されている可能性があります。 [/home/judge/data/code/main.csproj]
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

// See https://aka.ms/new-console-template for more information
using System.Collections;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

internal class Program
{
    private const long mod = 998244353;

    public static long mod_pow(long x, long n, long m = mod)
    {
        x %= m;
        if (x < 0) x += m;
        long res = 1;
        while (n > 0)
        {
            if ((n & 1) != 0) res = res * x % m;
            x = x * x % m;
            n >>= 1;
        }

        return res;
    }
    public struct perm
    {
        public List<int> fact;
        public List<int> factinv;

        public perm(int n)
        {
            fact = new List<int>(n);
            factinv = new List<int>(n);
            fact.Add(1);
            for (int i = 1; i < n; i++)
            {
                long val = fact.Last();
                val = val * i % mod;
                fact.Add((int)val);
            }

            long las = fact.Last();
            long cur = mod_pow(las, mod - 2);
            factinv.Add((int)cur);
            for (int i = n - 1; i > 0; i--)
            {
                long val = factinv.Last();
                val = val * i % mod;
                factinv.Add((int)val);
            }

            factinv.Reverse();
        }

        public int comb(int a, int b)
        {
            if (a < 0 || b < 0 || a < b) return 0;
            long res = fact[a];
            res = res * factinv[b] % mod;
            res = res * factinv[a - b] % mod;
            return (int)res;
        }
        
    }
    public struct BIT
    {
        public int n;
        public List<int> node;

        public BIT(int n_)
        {
            n = n_;
            node = new List<int>(n);
            for(int i=0;i<n;i++)node.Add(0);
        }

        public void add(int a, int w)
        {
            for (int i = a; i < n; i |= i + 1) node[i] += w;
        }

        public int sum(int a)
        {
            int res = 0;
            for (int i = a - 1; i >= 0; i = (i & (i + 1)) - 1) res += node[i];
            return res;
        }

        public int sum(int a, int b)
        {
            return sum(b) - sum(a);
        }
    }
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        string s = n.ToString();
        var st = new HashSet<long>();
        for (int i = 0; i <= s.Length; i++)
        {
            for (int ad = 0; ad < 10; ad++)
            {
                if (i == 0 && ad == 0) continue;
                string ns = s;
                //Console.WriteLine(ad.ToString());
                ns=ns.Insert(i, ad.ToString());
                long val = long.Parse(ns);
                st.Add(val);
                //Console.WriteLine(ns);
            }
        }

        int ans = st.Count();
        Console.WriteLine(ans);
    }

    public static List<int> mkar(int n, int val)
    {
        List<int> res = new List<int>(n);
        for(int i=0;i<n;i++)res.Add(val);
        return res;
    }
}
0