結果

問題 No.2211 Frequency Table of GCD
ユーザー 👑 kakel-sankakel-san
提出日時 2023-10-24 22:37:12
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 788 ms / 2,000 ms
コード長 1,484 bytes
コンパイル時間 9,696 ms
コンパイル使用メモリ 159,124 KB
実行使用メモリ 224,452 KB
最終ジャッジ日時 2023-10-24 22:37:39
合計ジャッジ時間 23,163 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
32,760 KB
testcase_01 AC 81 ms
32,764 KB
testcase_02 AC 82 ms
32,712 KB
testcase_03 AC 112 ms
39,852 KB
testcase_04 AC 275 ms
62,228 KB
testcase_05 AC 432 ms
78,440 KB
testcase_06 AC 260 ms
61,992 KB
testcase_07 AC 393 ms
74,640 KB
testcase_08 AC 135 ms
57,372 KB
testcase_09 AC 121 ms
49,944 KB
testcase_10 AC 222 ms
70,704 KB
testcase_11 AC 167 ms
63,460 KB
testcase_12 AC 207 ms
71,640 KB
testcase_13 AC 244 ms
62,080 KB
testcase_14 AC 244 ms
64,168 KB
testcase_15 AC 222 ms
56,220 KB
testcase_16 AC 238 ms
63,772 KB
testcase_17 AC 374 ms
73,820 KB
testcase_18 AC 562 ms
82,064 KB
testcase_19 AC 541 ms
82,064 KB
testcase_20 AC 575 ms
82,072 KB
testcase_21 AC 550 ms
82,076 KB
testcase_22 AC 560 ms
82,072 KB
testcase_23 AC 135 ms
37,892 KB
testcase_24 AC 762 ms
79,944 KB
testcase_25 AC 184 ms
71,336 KB
testcase_26 AC 83 ms
32,764 KB
testcase_27 AC 541 ms
82,048 KB
testcase_28 AC 788 ms
224,452 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (104 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var a = NList;
        var pcount = new int[m + 1];
        foreach (var ai in a) foreach (var p in PList(ai)) ++pcount[p];
        var ans = new long[m + 1];
        var mod = 998_244_353;
        for (var i = m; i > 0; --i)
        {
            var sub = 1L;
            for (var j = 0; j < pcount[i]; ++j) sub = (sub << 1) % mod;
            --sub;
            for (var j = i * 2; j < ans.Length; j += i)
            {
                sub = (sub + mod - ans[j]) % mod;
            }
            ans[i] = sub;
        }
        WriteLine(string.Join("\n", ans.Skip(1)));
    }
    static List<int> PList(int n)
    {
        var ans = new List<int>();
        var rev = new List<int>();
        for (var i = 1; i * i <= n; ++i)
        {
            if (n % i == 0)
            {
                ans.Add(i);
                if (i * i < n) rev.Add(n / i);
            }
        }
        rev.Reverse();
        return ans.Concat(rev).ToList();
    }
}
0