結果

問題 No.1723 [Cherry 3rd Tune *] Dead on
ユーザー bluemegane
提出日時 2021-10-30 07:27:32
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,127 bytes
コンパイル時間 1,025 ms
コンパイル使用メモリ 109,640 KB
実行使用メモリ 26,440 KB
最終ジャッジ日時 2024-10-07 13:26:35
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = long.Parse(line[0]);
        var a = long.Parse(line[1]);
        var y = long.Parse(line[2]);
        var b = long.Parse(line[3]);
        Console.WriteLine(getAns(x, a, y, b) ? "Yes" : "No");
    }
    static bool getAns(long x, long a, long y, long b)
    {
        var d = PF(x);
        var d2 = PF(y);
        foreach (var t in d2)
        {
            if (!d.ContainsKey(t.Key)) return false;
            var bb = t.Value * b;
            var aa = d[t.Key] * a;
            if (aa < bb) return false;
        }
        return true;
    }

    static Dictionary<long, long> PF(long n)
    {
        var d = new Dictionary<long, long>();
        for (long i = 2; i * i <= n; i++)
        {
            if (n % i != 0) continue;
            var x = 0L;
            while (n % i == 0)
            {
                x++;
                n /= i;
            }
            d[i] = x;
        }
        if (n != 1) d[n] = 1;
        return d;
    }
}
0