結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー mbanmban
提出日時 2017-04-12 17:00:36
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,189 bytes
コンパイル時間 2,510 ms
コンパイル使用メモリ 106,540 KB
実行使用メモリ 22,836 KB
最終ジャッジ日時 2023-09-25 13:07:24
合計ジャッジ時間 6,844 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,812 KB
testcase_01 AC 58 ms
20,608 KB
testcase_02 AC 58 ms
22,708 KB
testcase_03 AC 57 ms
20,788 KB
testcase_04 AC 58 ms
20,596 KB
testcase_05 AC 60 ms
22,716 KB
testcase_06 AC 58 ms
20,668 KB
testcase_07 AC 58 ms
20,608 KB
testcase_08 AC 58 ms
20,772 KB
testcase_09 AC 57 ms
20,664 KB
testcase_10 AC 58 ms
18,624 KB
testcase_11 AC 58 ms
18,720 KB
testcase_12 AC 58 ms
20,860 KB
testcase_13 AC 57 ms
20,696 KB
testcase_14 AC 59 ms
20,620 KB
testcase_15 AC 58 ms
20,676 KB
testcase_16 AC 59 ms
22,700 KB
testcase_17 AC 56 ms
18,812 KB
testcase_18 AC 57 ms
20,720 KB
testcase_19 AC 58 ms
18,796 KB
testcase_20 AC 59 ms
20,860 KB
testcase_21 AC 58 ms
20,868 KB
testcase_22 AC 59 ms
20,736 KB
testcase_23 AC 58 ms
20,736 KB
testcase_24 AC 59 ms
20,660 KB
testcase_25 AC 61 ms
20,824 KB
testcase_26 AC 59 ms
20,716 KB
testcase_27 AC 60 ms
22,608 KB
testcase_28 AC 60 ms
20,660 KB
testcase_29 AC 59 ms
20,752 KB
testcase_30 AC 62 ms
20,820 KB
testcase_31 AC 59 ms
22,792 KB
testcase_32 AC 59 ms
20,588 KB
testcase_33 AC 61 ms
22,780 KB
testcase_34 AC 59 ms
20,696 KB
testcase_35 AC 60 ms
22,788 KB
testcase_36 AC 60 ms
22,820 KB
testcase_37 AC 61 ms
20,676 KB
testcase_38 AC 60 ms
22,692 KB
testcase_39 AC 63 ms
20,680 KB
testcase_40 AC 63 ms
20,608 KB
testcase_41 AC 67 ms
22,836 KB
testcase_42 AC 61 ms
20,864 KB
testcase_43 AC 59 ms
18,744 KB
testcase_44 AC 59 ms
18,736 KB
testcase_45 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 System.Linq;

class Program
{
    static void Main(string[] args)
    {
        new Magatro().Solve();
    }
}

public class Magatro
{
    private long H, L;

    private void Scan()
    {
        string[] s = Console.ReadLine().Split(' ');
        H = long.Parse(s[1]);
        L = long.Parse(s[0]);
    }

    public void Solve()
    {
        Scan();
        int iMax = (int)Math.Sqrt(H);
        long max = -1;
        long ans = -1;
        for (long j = iMax; j >= 2; j--)
        {
            if (max > j)
            {
                break;
            }
            for (long i = H / j; i >= j; i--)
            {
                if (i * j < L)
                {
                    break;
                }
                long l = i * j;
                long p = Prime(l);
                if (max < p)
                {
                    max = p;
                    ans = l;
                }
            }
        }

        Console.WriteLine(ans);
    }

    private long Prime(long l)
    {
        for (long i = 2; i * i <= l; i++)
        {
            if (l % i == 0) return i;
        }
        return l;
    }
}
0