結果

問題 No.1514 Squared Matching
ユーザー 👑 kakel-sankakel-san
提出日時 2024-06-12 23:21:12
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 1,124 ms / 4,000 ms
コード長 865 bytes
コンパイル時間 14,406 ms
コンパイル使用メモリ 168,756 KB
実行使用メモリ 498,552 KB
最終ジャッジ日時 2024-06-12 23:21:47
合計ジャッジ時間 32,275 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
28,416 KB
testcase_01 AC 1,124 ms
420,908 KB
testcase_02 AC 49 ms
28,672 KB
testcase_03 AC 49 ms
28,544 KB
testcase_04 AC 50 ms
28,412 KB
testcase_05 AC 47 ms
28,928 KB
testcase_06 AC 68 ms
36,136 KB
testcase_07 AC 206 ms
104,612 KB
testcase_08 AC 915 ms
406,744 KB
testcase_09 AC 945 ms
359,508 KB
testcase_10 AC 883 ms
387,036 KB
testcase_11 AC 880 ms
401,460 KB
testcase_12 AC 1,033 ms
411,936 KB
testcase_13 AC 931 ms
417,040 KB
testcase_14 AC 937 ms
419,112 KB
testcase_15 AC 922 ms
419,976 KB
testcase_16 AC 976 ms
420,676 KB
testcase_17 AC 992 ms
420,676 KB
testcase_18 AC 1,002 ms
420,824 KB
testcase_19 AC 1,000 ms
420,804 KB
testcase_20 AC 913 ms
420,852 KB
testcase_21 AC 937 ms
421,104 KB
testcase_22 AC 224 ms
108,108 KB
testcase_23 AC 429 ms
186,652 KB
testcase_24 AC 584 ms
264,244 KB
testcase_25 AC 777 ms
498,552 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var dp = new int[n + 1];
        for (var i = 1; i <= n; ++i) dp[i] = i;
        for (var i = 2; i * i <= n; ++i)
        {
            for (var j = i * i; j <= n; j += i * i)
            {
                while(dp[j] % (i * i) == 0) dp[j] /= i * i;
            }
        }
        var ans = 0L;
        var dic = new int[n + 1];
        for (var i = 1; i <= n; ++i)
        {
            ans += dic[dp[i]] * 2 + 1;
            ++dic[dp[i]];
        }
        WriteLine(ans);
    }
}
0