結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー 14番14番
提出日時 2016-09-01 18:19:07
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 260 ms / 1,000 ms
コード長 1,832 bytes
コンパイル時間 2,565 ms
コンパイル使用メモリ 105,940 KB
実行使用メモリ 44,736 KB
最終ジャッジ日時 2023-08-22 06:19:40
合計ジャッジ時間 8,057 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,880 KB
testcase_01 AC 65 ms
23,876 KB
testcase_02 AC 62 ms
21,912 KB
testcase_03 AC 82 ms
23,620 KB
testcase_04 AC 63 ms
23,836 KB
testcase_05 AC 257 ms
44,648 KB
testcase_06 AC 160 ms
31,352 KB
testcase_07 AC 64 ms
23,964 KB
testcase_08 AC 62 ms
21,804 KB
testcase_09 AC 62 ms
21,792 KB
testcase_10 AC 63 ms
21,952 KB
testcase_11 AC 63 ms
23,988 KB
testcase_12 AC 64 ms
21,972 KB
testcase_13 AC 62 ms
21,872 KB
testcase_14 AC 64 ms
21,920 KB
testcase_15 AC 64 ms
21,856 KB
testcase_16 AC 63 ms
22,040 KB
testcase_17 AC 62 ms
21,744 KB
testcase_18 AC 63 ms
23,896 KB
testcase_19 AC 83 ms
25,784 KB
testcase_20 AC 119 ms
27,072 KB
testcase_21 AC 88 ms
24,088 KB
testcase_22 AC 84 ms
23,776 KB
testcase_23 AC 99 ms
27,440 KB
testcase_24 AC 120 ms
29,104 KB
testcase_25 AC 156 ms
30,920 KB
testcase_26 AC 156 ms
30,916 KB
testcase_27 AC 76 ms
22,740 KB
testcase_28 AC 105 ms
25,756 KB
testcase_29 AC 153 ms
32,832 KB
testcase_30 AC 81 ms
25,464 KB
testcase_31 AC 137 ms
30,496 KB
testcase_32 AC 155 ms
32,988 KB
testcase_33 AC 260 ms
41,160 KB
testcase_34 AC 258 ms
44,736 KB
testcase_35 AC 237 ms
41,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Text;
using System.Linq;


class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int kamoCount = inpt[0];
        int maxX = inpt[1];
        int[] primeList = this.GetPrimeNumbers(maxX);

        long ans = 0;
        for (int i = 0; i < primeList.Length; i++)
        {
            int prime = primeList[i];
            long pos = ((long)kamoCount - 1) * prime;
            if (pos > maxX)
            {
                break;
            }

            ans += (maxX - (pos) + 1);
        }
        Console.WriteLine(ans);


    }

    private int[] GetPrimeNumbers(int max)
    {
        bool[] flag = new bool[max + 1];
        List<int> ans = new List<int>();
        for (int i = 2; i < flag.Length; i++)
        {
            if (!flag[i])
            {
                ans.Add(i);
                for (int j = 1; j <= max / i; j++)
                {
                    flag[i * j] = true;
                }
            }

        }
        return ans.ToArray();
    }


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


8 964853






";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0