結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
28,368 KB
testcase_01 AC 97 ms
26,252 KB
testcase_02 AC 99 ms
30,364 KB
testcase_03 WA -
testcase_04 AC 98 ms
28,280 KB
testcase_05 AC 99 ms
30,320 KB
testcase_06 AC 97 ms
28,308 KB
testcase_07 AC 98 ms
28,240 KB
testcase_08 AC 98 ms
28,320 KB
testcase_09 AC 98 ms
28,272 KB
testcase_10 AC 99 ms
28,356 KB
testcase_11 AC 99 ms
28,484 KB
testcase_12 AC 98 ms
28,280 KB
testcase_13 AC 97 ms
30,388 KB
testcase_14 AC 97 ms
28,368 KB
testcase_15 AC 97 ms
28,256 KB
testcase_16 AC 97 ms
28,364 KB
testcase_17 AC 97 ms
28,288 KB
testcase_18 AC 96 ms
30,336 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 97 ms
28,320 KB
testcase_22 AC 97 ms
28,416 KB
testcase_23 AC 99 ms
30,368 KB
testcase_24 AC 98 ms
30,348 KB
testcase_25 WA -
testcase_26 AC 98 ms
28,336 KB
testcase_27 AC 99 ms
30,352 KB
testcase_28 AC 99 ms
28,264 KB
testcase_29 AC 98 ms
28,316 KB
testcase_30 AC 99 ms
30,380 KB
testcase_31 AC 98 ms
30,364 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 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;
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);
        int 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