結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー kakel-san
提出日時 2021-10-29 21:59:49
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,289 bytes
コンパイル時間 1,186 ms
コンパイル使用メモリ 112,784 KB
実行使用メモリ 29,584 KB
最終ジャッジ日時 2024-10-07 11:14:19
合計ジャッジ時間 4,309 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 50
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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

class yuki320
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (x, a, y, b) = (c[0], c[1], c[2], c[3]);

        var xp = PDiv(x);
        var yp = PDiv(y);
        foreach (var kv in yp)
        {
            if (!xp.ContainsKey(kv.Key) || xp[kv.Key] * a < kv.Value * b)
            {
                WriteLine("No");
                return;
            }
        }
        WriteLine("Yes");
    }
    static Dictionary<long, long> PDiv(long n)
    {
        var dic = new Dictionary<long, long>();
        var tmp = n;
        while (tmp % 2 == 0)
        {
            tmp /= 2;
            if (dic.ContainsKey(2)) ++dic[2];
            else dic.Add(2, 1);
        }
        for (var p = 3L; p * p <= n; p += 2)
        {
            while (tmp % p == 0)
            {
                tmp /= p;
                if (dic.ContainsKey(p)) ++dic[p];
                else dic.Add(p, 1);
            }
            if (tmp == 1) break;
        }
        if (tmp > 1) dic.Add(tmp, 1);
        return dic;
    }
}
0