結果

問題 No.2751 429-like Number
ユーザー 👑 kakel-sankakel-san
提出日時 2024-05-22 23:29:31
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 1,699 bytes
コンパイル時間 8,126 ms
コンパイル使用メモリ 170,416 KB
実行使用メモリ 38,560 KB
最終ジャッジ日時 2024-05-22 23:29:49
合計ジャッジ時間 16,244 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
34,944 KB
testcase_01 AC 84 ms
38,560 KB
testcase_02 AC 82 ms
31,608 KB
testcase_03 AC 85 ms
31,616 KB
testcase_04 AC 95 ms
31,616 KB
testcase_05 AC 86 ms
31,616 KB
testcase_06 AC 85 ms
31,616 KB
testcase_07 AC 323 ms
32,128 KB
testcase_08 AC 92 ms
32,256 KB
testcase_09 AC 1,020 ms
32,256 KB
testcase_10 AC 1,028 ms
32,256 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (97 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();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var p = new List<int>();
        for (var i = 2; i < 100000; ++i)
        {
            if (IsPrime(i)) p.Add(i);
        }
        var q = NN;
        var ans = new bool[q];
        for (var i = 0; i < q; ++i)
        {
            var a = long.Parse(ReadLine());
            var x = 0;
            while (x < p.Count)
            {
                if (a % p[x] == 0) break;
                ++x;
            }
            if (x == p.Count) continue;
            var y = x;
            while (y < p.Count)
            {
                if (a / p[x] % p[y] == 0) break;
                ++y;
            }
            if (y == p.Count) continue;
            var z = a / p[x] / p[y];
            if (IsPrime(z)) ans[i] = true;
        }
        WriteLine(string.Join("\n", ans.Select(f => f ? "Yes" : "No")));
    }
    static bool IsPrime(long n)
    {
        if (n == 1) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;
        int i = 3;
        while (i * i <= n)
        {
            if (n % i == 0) return false;
            i = i + 2;
        }
        return true;
    }
}
0