結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー mbanmban
提出日時 2017-01-09 22:50:37
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,231 bytes
コンパイル時間 2,358 ms
コンパイル使用メモリ 108,572 KB
実行使用メモリ 30,464 KB
最終ジャッジ日時 2023-08-22 21:54:58
合計ジャッジ時間 7,321 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
28,352 KB
testcase_01 AC 97 ms
28,404 KB
testcase_02 AC 98 ms
28,340 KB
testcase_03 AC 99 ms
28,348 KB
testcase_04 AC 96 ms
28,308 KB
testcase_05 AC 97 ms
26,248 KB
testcase_06 AC 97 ms
30,368 KB
testcase_07 AC 97 ms
28,292 KB
testcase_08 AC 97 ms
28,296 KB
testcase_09 AC 97 ms
28,320 KB
testcase_10 AC 100 ms
30,340 KB
testcase_11 AC 97 ms
28,324 KB
testcase_12 AC 96 ms
28,312 KB
testcase_13 AC 95 ms
28,392 KB
testcase_14 AC 96 ms
30,464 KB
testcase_15 AC 96 ms
28,296 KB
testcase_16 AC 97 ms
30,396 KB
testcase_17 AC 96 ms
28,352 KB
testcase_18 AC 97 ms
28,372 KB
testcase_19 AC 98 ms
28,292 KB
testcase_20 AC 97 ms
28,484 KB
testcase_21 AC 96 ms
30,460 KB
testcase_22 AC 98 ms
30,372 KB
testcase_23 AC 96 ms
30,344 KB
testcase_24 AC 97 ms
28,312 KB
testcase_25 AC 101 ms
28,332 KB
testcase_26 AC 97 ms
28,344 KB
testcase_27 AC 97 ms
26,372 KB
testcase_28 AC 98 ms
30,356 KB
testcase_29 AC 97 ms
28,364 KB
testcase_30 AC 96 ms
28,244 KB
testcase_31 AC 96 ms
30,448 KB
testcase_32 AC 97 ms
30,364 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 100 ms
30,424 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatro
{
    static int N,L;
    static Scanner sc = new Scanner();
    static int[] Primes;
 static void Main()
    {
        N = sc.NextInt();
        L = sc.NextInt();
        int[] Primes = PrimeCalc(4000000);
        long ans = 0;
        for(int i = 0; i < Primes.Length; i++)
        {
            int q = Primes[i] * (N - 1);
            if (L>=q)
            {
                ans += (L - q + 1);
            }
            else
            {
                break;
            }
        }
        Console.WriteLine(ans);
    }
    static int[] PrimeCalc(int max)
    {
        int loop = (int)Math.Sqrt(max);
        bool[] num = new bool[max + 1];
        num[0] = true;
        num[1] = true;
        for(int i = 2 * 2; i <= max; i += 2)
        {
            num[i] = true;
        }
        for(int i = 3; i <= loop; i += 2)
        {
            if (!num[i])
            {
                for(int j = i + i; j <= max; j += i)
                {
                    num[j] = true;
                }
            }
        }
        List<int> res = new List<int>();
        res.Add(2);
        for(int i = 3; i <= max; i += 2)
        {
            if (!num[i])
            {
                res.Add(i);
            }
        }
        return res.ToArray();
    }
}

public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;
    public Scanner(char separator=' ')
    {
        Index = 0;
        Separator = separator;
    }
    public string Next()
    {
        string result;
        if (S == null || Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    } 
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}
0