結果

問題 No.300 平方数
ユーザー bluemeganebluemegane
提出日時 2020-09-10 11:31:59
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,496 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 68,152 KB
実行使用メモリ 27,244 KB
最終ジャッジ日時 2023-08-24 15:36:21
合計ジャッジ時間 9,529 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,476 KB
testcase_01 AC 61 ms
21,412 KB
testcase_02 AC 157 ms
23,732 KB
testcase_03 AC 60 ms
21,548 KB
testcase_04 AC 61 ms
21,504 KB
testcase_05 WA -
testcase_06 AC 61 ms
19,668 KB
testcase_07 AC 61 ms
21,476 KB
testcase_08 AC 61 ms
23,500 KB
testcase_09 AC 63 ms
21,640 KB
testcase_10 AC 62 ms
21,484 KB
testcase_11 AC 62 ms
21,644 KB
testcase_12 AC 63 ms
23,596 KB
testcase_13 WA -
testcase_14 AC 69 ms
21,484 KB
testcase_15 AC 128 ms
23,260 KB
testcase_16 AC 118 ms
24,848 KB
testcase_17 AC 216 ms
25,104 KB
testcase_18 AC 69 ms
23,520 KB
testcase_19 AC 106 ms
22,584 KB
testcase_20 WA -
testcase_21 AC 216 ms
25,136 KB
testcase_22 AC 193 ms
24,660 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 180 ms
24,336 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 178 ms
26,344 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 100 ms
20,208 KB
testcase_34 AC 199 ms
24,808 KB
testcase_35 AC 142 ms
21,308 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 153 ms
23,824 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 140 ms
23,448 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Hello
{
    static void Main()
    {
        var x = long.Parse(Console.ReadLine().Trim());
        var m = (int)Sqrt(x) + 1;
        var a = GeneratePrime(m);
        var d = getDic(x, a);
        getAns(d);
    }
    static void getAns(Dictionary<long, int> d)
    {
        var res = 1L;
        foreach (var x in d)
        {
            if (x.Value % 2 == 1) res *= x.Key;
        }
        Console.WriteLine(res);
    }
    static Dictionary<long, int> getDic(long x, List<int> a)
    {
        var acount = a.Count();
        var d = new Dictionary<long, int>();
        for (int i = 0; i < acount; i++)
        {
            if (a[i] > x) break;
            while (true)
            {
                if (x % a[i] == 0)
                {
                    if (d.ContainsKey(a[i])) d[a[i]]++;
                    else d[a[i]] = 1;
                    x /= a[i];
                }
                else break;
            }
        }
        if (d.Count() == 0) d[x] = 1;
        return d;
    }
    static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Math.Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }

}
0